Created
June 5, 2018 15:37
-
-
Save comm1x/ea8a39ee37cd7c66e87c90ab14cf355c to your computer and use it in GitHub Desktop.
mkroundcorners - script for making round corners for png-images
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
#!/usr/bin/env bash | |
set -e | |
if [ $# -ne 3 ]; then | |
echo 'mkroundcorners - script for making round corners for png-images.' | |
echo 'Usage: mkroundcorners source.png 40 target.png' | |
exit 0 | |
fi | |
SRC=$1 | |
R=$2 | |
DST=$3 | |
MASK=mkroundcorners-tmp-mask.png | |
W=$(identify -format '%w' ${SRC}) | |
H=$(identify -format '%h' ${SRC}) | |
convert -size "${W}x${H}" xc:none -draw "roundrectangle 0,0,${W},${H},${R},${R}" ${MASK} | |
convert ${SRC} -matte ${MASK} -compose DstIn -composite ${DST} | |
rm ${MASK} | |
echo 'Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment