Skip to content

Instantly share code, notes, and snippets.

@comm1x
Created June 5, 2018 15:37
Show Gist options
  • Save comm1x/ea8a39ee37cd7c66e87c90ab14cf355c to your computer and use it in GitHub Desktop.
Save comm1x/ea8a39ee37cd7c66e87c90ab14cf355c to your computer and use it in GitHub Desktop.
mkroundcorners - script for making round corners for png-images
#!/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