0

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

3 Answers 3

1

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

1
  • I edited this response by mistake. PLEASE cancel my edit and roll back.
    – Vishal
    Mar 15, 2020 at 14:14
1

In 2023 with Ventura, this seems to be the closest I can get to reproducing the drop shadow:

convert test.png \( +clone -background black -shadow 40x50+0+36 \) +swap -background transparent -layers merge +repage test-shadow.png
0

The following appears to work. I've done it twice -- once to show the shadow more explicitly, and then once to show the desired, finished output.

# adds the shadow
convert source.png \( +clone -background black -shadow 100x40+0+16 \) \
+swap -background none -layers merge +repage output.png

# adds the additional space like MacOSX
convert output.png -bordercolor none -border 32 target.png

enter image description here

Caveats:

  1. The padding on should be 20px less on the top and 20px more on the bottom; this solution is not perfect in that regard.

  2. The OSX screenshow draws a white border around the image, including the rounded corners. I could not duplicate that.

  3. The shadow from osx screencapture looks more blurred but I don't know how to measure the blue and calibrate the solution to that.

Highlighted shadow to show shape and blurring

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.