add dropshadow to image with imagemagick

Tiny shell script to add drop shadow to a PNG image with the use of convert(1) from ImageMagick and save the output as a new file with .shadow appended to the input image file name, before the suffix.

#!/bin/sh
convert $1 -bordercolor none -border 12 \( +clone -background black \
-shadow 80x3+3+3 \) +swap -background white -layers merge +repage \
`basename $1 .png`.shadow.png
exit

where $1 is the input image filename.

I should properly rewrite this script so it performs some error checking at least, but it’s enough for my use case as it is so I haven’t improved it yet. Hopefully someone finds it useful as well.

I don’t take credit for the actual command, it’s a combination of directives I found on some forum answer online, but it’s easier to get back to this note should I need to.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.