image stack and composite

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
simont
Posts: 4
Joined: 2012-08-02T21:33:47-07:00
Authentication code: 15

image stack and composite

Post by simont »

The following two commands give me the desired image:
convert foo-Alpha.jpg -alpha copy foo-Raw\ Shadow.jpg -alpha copy mask4.png
convert mask4.png foo.jpg -compose atop -composite final.png

However when I attempt to combine it into one single call using image stacking it does not work:
convert \( foo-Alpha.jpg -alpha copy foo-Raw\ Shadow.jpg -alpha copy) foo.jpg -compose atop -composite final.png

What am I doing wrong?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: image stack and composite

Post by fmw42 »

convert \( foo-Alpha.jpg -alpha copy foo-Raw\ Shadow.jpg -alpha copy) foo.jpg -compose atop -composite final.png
Unless you have some typos or I misundestand, you need to
1) remove the space between foo-Raw\ Shadow.jpg -- I presume foo-Raw is a directory and Shadow.jpg does not start with a space in the name. If it does, then put quotes around "foo-Raw\ Shadow.jpg"
2) add a space after -alpha copy and put an escape before the last paren

convert \( foo-Alpha.jpg -alpha copy foo-Raw\Shadow.jpg -alpha copy \) foo.jpg -compose atop -composite final.png
simont
Posts: 4
Joined: 2012-08-02T21:33:47-07:00
Authentication code: 15

Re: image stack and composite

Post by simont »

I wish it were that easy. The foo-Raw\ Shadow.jpg is indeed correct. There is a space in the filename. Just for grins I renamed the file w/o a space. I fixed the space before the last \) though. This still doesn't work:
convert \( foo-Alpha.jpg -alpha copy foo-RawShadow.jpg -alpha copy \) foo.jpg -compose atop -composite final.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: image stack and composite

Post by fmw42 »

foo-Alpha.jpg -alpha copy foo-RawShadow.jpg -alpha copy
I do not understand this operation. It appears to be creating two images of the alpha channels from foo-Alpha.jpg and foo-RawShadow.jpg. Thus your total command line has 3 images to composite with atop. Unless the last image foo.jpg is a mask, I am not sure that works.

Please clarify what you are trying to do and/or provide links to your images, so others can test.
simont
Posts: 4
Joined: 2012-08-02T21:33:47-07:00
Authentication code: 15

Re: image stack and composite

Post by simont »

Sorry for not explaining. I have 3 jpgs. 1 is a color .jpg with a shadow, another is an alpha (b&w) jpg, lastly is a shadow .jpg. The color .jpg has a background I want to remove, the alpha .jpg gives me the cutout shape I want and the shadow is the same shadow as the color image minus the color image itself.

The following commands give me the picture i want:
composite goo-Alpha.jpg -alpha copy goo-Raw\ Shadow.jpg -alpha copy goo-Mask.png
composite goo.jpg goo-Mask.png -compose atop goo4.png

I think there should be a way to combine all of this into one command but I can't seem to figure it out.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: image stack and composite

Post by fmw42 »

try


convert \( "goo-Raw\ Shadow.jpg" -alpha copy \) \
\( goo-Alpha.jpg -alpha \) -compose over -composite \
goo.jpg -compose atop goo4.png

Note the quotes around the first image due to the space in the name.

if on windows, remove the \ from before ( and ) and change \ to ^ at the end of the lines. See http://www.imagemagick.org/Usage/windows/

If that does not work, please post links to your input and output images so we can test with them.
simont
Posts: 4
Joined: 2012-08-02T21:33:47-07:00
Authentication code: 15

Re: image stack and composite

Post by simont »

Thanks so much. I took what you had wrote and came up with this to get exactly what I wanted:

convert \( "goo-Raw Shadow.jpg" -alpha copy \) \( goo-Alpha.jpg -alpha copy \) -compose over -composite goo.jpg -compose atop -composite goo5.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: image stack and composite

Post by anthony »

simont wrote:

Code: Select all

convert \( foo-Alpha.jpg -alpha copy foo-RawShadow.jpg -alpha copy \) foo.jpg -compose atop -composite final.png
Hmmm you make a alpha copy of the first image add a second then get an alpha copy of both.

That first will become all white (no alpha to copy)! Then as fred said you have three images for the compose, the third being a 'masking' image for the composition (actually a negated write mask).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply