Search code examples
imagemagick

Create MacOS style screenshots with dropshadow using Imagemagick


How do I add the drop shadow to any image with imagemagick to create the same effect that the screenshot on MacOS adds to screenshots when screencapture shadow is true?

I am showing before and after to clarify the effect I am seeking.

Source image

Target image

I have tried to identify the shape of the shadow in the target picture Shadow profile in Target


Solution

  • I think this is pretty similar, but you can play around with the parameters:

    convert screenshot.png \( +clone -background black -shadow 50x50+30+30 \) +swap -background white -layers merge +repage result.png
    

    enter image description here


    Here I change the shadow colour to magenta and shift it and place it on a yellow background layer so you can see the effect:

    convert screenshot.png \( +clone -background magenta -shadow 200x50+30+30 \) +swap -background yellow  -layers merge +repage result.png
    

    enter image description here