Need help with merging images and adding drop shadow

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Need help with merging images and adding drop shadow

Post by jauson »

I've created a working script that does this separately, but no luck trying to have it do it in 1 command.

Code: Select all

convert 1.png \
    \( +clone  -background gray10 -shadow 80x14+25+25 \) +swap \
    -background none   -layers merge  +repage   1m.png

Code: Select all

convert \
        -page +2400+0   1m.png   \
        -page +2000+0   2m.png   \
        -page +1600+0   3m.png   \
        -page +1200+0   4m.png \
        -page +800+0    5m.png  \
        -page +400+0    6m.png \
        -page +0+0      7m.png \
        -background none  -layers merge  +repage  layerstest.png

What I'm trying to do is something like this with no luck:

Code: Select all

convert \
        -page +2400+0   1m.png   \
        \( +clone  -background gray45  -shadow 10x30+0+0 \) +swap -background none   -layers merge \
        -page +2000+0   2m.png   \
        \( +clone  -background gray45  -shadow 10x30+0+0 \) +swap -background none   -layers merge \
        -page +1600+0   3m.png   \
        \( +clone  -background gray45  -shadow 10x30+0+0 \) +swap -background none   -layers merge \
        -page +1200+0   4m.png \
        -page +800+0    5m.png  \
        -page +400+0    6m.png \
        -page +0+0      7m.png \
        -background none  -layers merge  +repage  layerstest.png

Update, Ater a few more tries my working solution:

Code: Select all

convert \
        -page +2400+0   1m.png   \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +2000+0   2m.png   \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +1600+0   3m.png   \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +1200+0   4m.png \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +800+0    5m.png  \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +400+0    6m.png \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -page +0+0      7m.png \
        \( +clone  -background gray10 -shadow 80x14+25+25 \)  +swap -background none   \
        -background none  -layers merge  +repage  layerstest.png
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: Need help with merging images and adding drop shadow

Post by jauson »

One problem I'm having is -page doesn't resize the layer like suggested.

For example:

-page 100x100+2400+0 1m.png

doesn't give me a 100x100 1m image at that offset.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Need help with merging images and adding drop shadow

Post by Bonzo »

You could check out the examples here: http://www.imagemagick.org/Usage/layers/
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: Need help with merging images and adding drop shadow

Post by jauson »

Thanks Bonzo, I've been there, the -page still isn't resizing. I must be missing something.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Need help with merging images and adding drop shadow

Post by Bonzo »

I use this method to resize and move the image with the Anthony/Tomas Zathurecky code linked to above:

Code: Select all

convert \
    \( holocaust_tn.gif -thumbnail 500x500 \
          -background none  -rotate 5 -repage +0+0 \) \
    \
    \( spiral_stairs_tn.gif  -thumbnail 500x500 \
          -background none -rotate -15 -repage -90+60 \) \
    \( -clone 0   -background black -shadow 70x3+4+7 \
       -clone 1   -background black -compose DstATop -layers merge \
       -trim \) \
    \( -clone 2,0 -background none  -compose Over -layers merge \) \
    -delete 0--2 \
    \
    \( chinese_chess_tn.gif  -thumbnail 500x500 \
          -background none -rotate 20 -repage +60+90 \) \
    \( -clone 0   -background black -shadow 70x3+4+7 \
       -clone 1   -background black -compose DstATop -layers merge \
       -trim \) \
    \( -clone 2,0 -background none  -compose Over -layers merge \) \
    -delete 0--2 \
    \
    \( +clone -background black -shadow 70x3+4+7 \) +swap \
    -background none -compose Over -layers merge +repage \
    layers_of_shadows.png
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: Need help with merging images and adding drop shadow

Post by jauson »

Am I wrong in thinking -page should be resizing a layer?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help with merging images and adding drop shadow

Post by fmw42 »

As far as I know -page by itself does not resize the image data, but may pad or crop due to the virtual canvas it creates. See

http://www.imagemagick.org/Usage/basics/#page
Post Reply