Last active
December 17, 2015 19:39
-
-
Save deltheil/5661675 to your computer and use it in GitHub Desktop.
Split in two parts, chop and join a transparent button image with ImageMagick.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function split { # file, target_size | |
_w=$(identify -format "%w" $1) | |
_dx=$(( ($_w - $2) / 2 )) | |
convert $1 -crop 50%x100% +repage parts.png | |
convert parts-0.png -gravity East -chop ${_dx}x0 left.png | |
convert parts-1.png -gravity West -chop ${_dx}x0 right.png | |
montage -background none left.png right.png -mode Concatenate -tile x1 out.png | |
rm parts*.png left.png right.png | |
} | |
split $1 $2 | |
echo "Done: out.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment