Drop shadow on watermark image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Drop shadow on watermark image

Post by dizee »

Hi, I'm trying to add a drop shadow to an image overlayed on another image.

---

This is almost what I want, but the image in the center needs a drop shadow:

/usr/bin/convert 'sample.png' -resize 1000x750! -resize 854x641! -crop 854x480+0+80! -modulate 50 -blur 0x10 -gravity None 'sample.png' -geometry 586.66666666667x440+133.66666666667+20 -compose src-over -composite -density 72 -units PixelsPerInch -quality 75 'sample1-nodropshadow.png'

https://www.dropbox.com/s/78qayx4g8ld8e ... w.png?dl=0

---

This is close, kind of, but obviously the full color image needs to be on top of the drop shadow...

/usr/bin/convert 'sample.png' -resize 1000x750! -resize 854x641! -crop 854x480+0+80! -modulate 50 -blur 0x10 -gravity None 'sample.png' -geometry 586.66666666667x440+133.66666666667+20 \( +clone -background black -shadow 50x10+5+5 \) +swap -compose src-over -composite -density 72 -units PixelsPerInch -quality 75 'sample10-ghost.png'

https://www.dropbox.com/s/03un5m79frj3m ... t.png?dl=0

---

What do I need???

Thanks much!!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by dizee »

fmw42 wrote: 2017-01-13T12:35:29-07:00 See http://www.imagemagick.org/Usage/blur/#shadow
Thanks, but I have looked all over the documentation and I just can't figure out the order to put it in my command... I'm generating the whole image with just one image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

Post your input images to some place such as dropbox.com and put the URLs here. Then we can try to give you the code to do the processing. What is your IM version and platform, since syntax may differ.
dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by dizee »

Sample image is from drupal
https://www.dropbox.com/s/tdl170zkose57 ... e.png?dl=0

ImageMagick 6.6.9-7 2016-11-29 Q16 on Linux
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

You cannot add a shadow to an image that already is merged. You need to upload both the background image and the foreground image that is to have a drop shadow.
dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by dizee »

How would I add a shadow to the center image PRIOR to merging it with the background?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

see the link that I referenced earlier. http://www.imagemagick.org/Usage/blur/#shadow
dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by dizee »

I understand how to do a shadow... but how do I combine it with the commands I have listed above to make a shadow on the center image before merging with the background??
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

That is why I asked you to provide both your input images, so I can send you a command that works. I do not want to try to analyze your command, since I have no way to test my suggestions.
dizee
Posts: 6
Joined: 2017-01-13T11:13:06-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by dizee »

It is with one image. If you look at the examples in the first post, you can see what I'm trying to accomplish.

In english, here are the steps I am taking on ONE image:
// resize original to fit 1000x1000
// blur
// darken
// crop to 854x480
// place original to fit 814x440 at center
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

It is late here. So I will work on this tomorrow for you, unless some one else on the forum wants to tackle it first. That is OK with me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

OK. So try this:

Code: Select all

convert sample.png \
\( -clone 0 -resize 1000x1000 -modulate 50 -blur 0x10 -gravity center -crop 854x480+0+0 +repage \) \
\( -clone 0 -resize 814x440 \) \
\( +clone -background black -shadow 80x3+5+5 \) \
\( -clone 3 -clone 2 -background none -layers merge +repage \) \
-delete 0,2,3 -gravity center -compose over -composite sample_result.png
Image

Is this what you want?
philmoz
Posts: 4
Joined: 2017-01-23T18:43:17-07:00
Authentication code: 1151

Re: Drop shadow on watermark image

Post by philmoz »

Drop shadows seem to be broken in 7.0.4-5 (OS X Sierra, installed via homebrew).
The command from the previous post, with the same sample image generates the result shown below.

Code: Select all

convert sample.png \
\( -clone 0 -resize 1000x1000 -modulate 50 -blur 0x10 -gravity center -crop 854x480+0+0 +repage \) \
\( -clone 0 -resize 814x440 \) \
\( +clone -background black -shadow 80x3+5+5 \) \
\( -clone 3 -clone 2 -background none -layers merge +repage \) \
-delete 0,2,3 -gravity center -compose over -composite sample_result.png
Note how the main image is transparent, not solid, and the shadow offset and borders are wrong.
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Drop shadow on watermark image

Post by fmw42 »

Looks like a bug in -layers merge. I have reported it. See viewtopic.php?f=3&t=31282
Post Reply