Page 1 of 1
ufff...join 2 convert commands
Posted: 2011-12-12T13:32:59-07:00
by terebentina
Hi,
I am trying to create some sort of poster preview, like this:

using this inner image:
and this outer image that should give the "wave" shape and has the shadow:
and this image for the displacement map:

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?
Re: ufff...join 2 convert commands
Posted: 2011-12-12T17:04:33-07:00
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
Re: ufff...join 2 convert commands
Posted: 2011-12-13T02:33:04-07:00
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
Re: ufff...join 2 convert commands
Posted: 2011-12-13T10:30:30-07:00
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
Re: ufff...join 2 convert commands
Posted: 2011-12-13T11:15:23-07:00
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.
Re: ufff...join 2 convert commands
Posted: 2011-12-14T21:29:39-07:00
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....