Friday, November 16, 2018

Adding shadow to images from the command-line (macos/linux)

When doing documentation, adding a shadow to images or screen grab makes the document come aline and helps break text from images.

For example the following image:

Is pretty "normal" and does not stand-out. However with a single command you can turn it into this:

You will need the ImageMagick package installed:

On macOS if you have brew installed it's as simple as running: brew install imagemagick

Then to add a shadow as shown above you simply have to run:

my_image="pi.png" ; cp ${my_image} ${my_image}_original ; convert ${my_image} \( -clone 0 -background gray -shadow 80x3+10+10 \) \( -clone 0 -background gray -shadow 80x3-5-5 \) -reverse -background none -layers merge +repage ${my_image}

Just change my_image="pi.png" to reflact the filename of the image to shich you want to add the shadow to. The above command will create a file with _original which is your original unmodified image.

No comments:

Post a Comment

Day-O: A customizable macOS clock replacement

At work we use week number milestones. Finding which week we are in is always a pain... Until I found Day-O (