Skip to content

Instantly share code, notes, and snippets.

@McGeekiest
Created July 7, 2016 18:51
Show Gist options
  • Save McGeekiest/f2c458c56cb5d20234c8df67f9a3e2c9 to your computer and use it in GitHub Desktop.
Save McGeekiest/f2c458c56cb5d20234c8df67f9a3e2c9 to your computer and use it in GitHub Desktop.
Flag composite
#!/bin/bash
# Combine two flags and add a "vs" overlay
# v0.1 (2016-07-07)
convert -size 600x800 gradient: gradient.png
convert gradient.png -rotate -90 gradient-left-orig.png
padright 100 black gradient-left-orig.png gradient-left.png
convert gradient-left.png -alpha copy gradient-left-mask.png
convert gradient-left-mask.png -rotate 180 gradient-right-mask.png
convert france.png gradient-left-mask.png -compose CopyOpacity -composite france-masked.png
convert germany.png gradient-right-mask.png -compose CopyOpacity -composite germany-masked.png
convert france-masked.png germany-masked.png -background black -layers merge flags-combined.png
convert img/vs.png -resize 160x160 ./vs.png
VSH=`identify -format '%h' vs.png`
VSW=`identify -format '%w' vs.png`
H=`identify -format '%h' flags-combined.png`
W=`identify -format '%w' flags-combined.png`
XOFF=`echo " ($W - $VSW) / 2" | bc`
YOFF=`echo " ($H - $VSH) / 2" | bc`
convert -size ${W}x${H} -page +0+0 flags-combined.png -page +${XOFF}+${YOFF} vs.png -background black -layers merge flags-vs.png
convert flags-vs.png -quality 93 flags-vs.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment