ufff...join 2 convert commands

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
terebentina
Posts: 10
Joined: 2011-11-10T14:37:46-07:00
Authentication code: 8675308

ufff...join 2 convert commands

Post by terebentina »

Hi,

I am trying to create some sort of poster preview, like this:
Image
using this inner image:
Image

and this outer image that should give the "wave" shape and has the shadow:
Image

and this image for the displacement map:
Image
The result image I'd like should have the inner image displaced a bit, to follow the wave from the outer image.

I made it work with 2 convert commands, I also made it work with 1 convert but without displacing the inner image but for the life of me I can't make it work completely with 1 convert command.

This works, but it's not displacing the inner image:

Code: Select all

convert outer.png \( inner.jpg -repage +30+30 -scale x597 \) +swap -mosaic result.jpg
This doesn't work:

Code: Select all

convert outer.png \( inner.jpg -repage +30+30 -scale x597 displacement.png -compose displace -define compose:args=20x0 -composite \) +swap -layers merge result.jpg

Any hints?
Last edited by terebentina on 2011-12-13T02:22:37-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ufff...join 2 convert commands

Post by fmw42 »

I cannot download your inner image.

You need to make a different and more appropriate displacement map separate from your shading. Apply the displacement to your image with a transparent background. Then shade the result.

see the whole section on http://www.imagemagick.org/Usage/mappin ... ement_maps
terebentina
Posts: 10
Joined: 2011-11-10T14:37:46-07:00
Authentication code: 8675308

Re: ufff...join 2 convert commands

Post by terebentina »

Meh, image hosting sites are really bad.

I updated the links above and I added the displacement map as well. I am using a proper displacement map, I just forgot to include it in the original post.
The "outer" image is used just for the margins of the poster, not using it for displacing.
Basically the steps should be: displace inner image and add outer on top for the margins and shadow.

The displacement part works:

Code: Select all

convert inner.jpg -scale x597 displacement.png -compose displace -define compose:args=20x0 -composite inner_displaced.jpg
The second convert command works using the result of the first and it's producing the desired result:

Code: Select all

convert outer.png \( inner_displaced.jpg -repage +30+30 \) +swap -mosaic result.jpg
But if I try to join the 2 commands into one it gives me weird results:

Code: Select all

convert outer.png \( inner.jpg -scale x597 displacement.png -compose displace -define compose:args=20x0 -composite -repage +30+30 \) +swap -mosaic result.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ufff...join 2 convert commands

Post by fmw42 »

Just a guess but you need to reset the compose method. Try this

convert outer.png \( inner.jpg -scale x597 displacement.png -compose displace -define compose:args=20x0 -composite -repage +30+30 \) +swap -compose over -mosaic result.jpg
terebentina
Posts: 10
Joined: 2011-11-10T14:37:46-07:00
Authentication code: 8675308

Re: ufff...join 2 convert commands

Post by terebentina »

I think you're right...my convert command is now a bit different cause I started over but, indeed, I made sure I had a compose + composite after each new image added in the stack and it works now.
Thanks for the help.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ufff...join 2 convert commands

Post by anthony »

WARNING: +compose does not reset to 'over' composition. All it does it turn off the 'global' compose setting, which forces, all images to fall back to whatever per-image compose setting is present (in source or overlay image). This is needed for read-in 'layered' images such as from gimp and photoshop, which may use a different compose setting for each individual layer image!

When a image is 'composed' the resulting image gets a per-image copy of the compose method that was used. This is something I regard as a bug, as once a compose method is used, its per-image compose setting should no longer be valid!

This is something that I have on my list to look at for IMv7 development which I hope to make more use of both 'global' and 'per-image' settings for various operations, (such as compose, distorts, etc.)

You must use -compose Over to reset the compose setting.

WARNING some formats save the per-image compose settings... Arrrggghhhh....
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply