Page 1 of 1

Use of smush when combining images

Posted: 2019-10-15T15:36:44-07:00
by shveicar
Hello
I'm trying to figure out how to bring one of the layers to the foreground.
So it was be on top. When I use the command:

Code: Select all

convert granite: rose: -background none -gravity east +smush -10 test.png
I get a good result

Image

but when I change the command:

Code: Select all

convert rose: granite: -background none -gravity west +smush -10 test.png
to get the image on the left, one of the layers hides under the other

Image

How to make a layer with a rose on top?
Thanks

Re: Use of smush when combining images

Posted: 2019-10-15T15:56:04-07:00
by fmw42
smush will not overlap. It simply adds space or removes space.

You will need to do a -mosaic or -layers merge. See

https://imagemagick.org/Usage/layers/#mosaic
https://imagemagick.org/Usage/layers/#merge

Re: Use of smush when combining images

Posted: 2019-10-15T16:34:26-07:00
by snibgo
Umm, smush can overlap.

As far as I know, smush always places the second on top of the first, and the third on top of that, and so on.

A couple of rotations will effectively reverse the order:

Code: Select all

convert granite: rose: -rotate 180 -background none -gravity west +smush -10 -rotate 180 rosegran.png
Image

Re: Use of smush when combining images

Posted: 2019-10-15T18:08:50-07:00
by fmw42
snibgo. Thanks I did not know that. I always thought it just added or deleted data as in the OP's original image. So I believe this does what you suggest:

Code: Select all

convert granite: rose: -reverse -background none -gravity east +smush -10 -flop granite_rose_smush.png
Image

Re: Use of smush when combining images

Posted: 2019-10-16T10:24:17-07:00
by shveicar
snibgo Many thanks for the tip, it is much more convenient than using other methods offered by fmw42

But there is such an interesting moment.
I have decomposed this animation into separate images (1-43.png) with using the utility FFmpeg

Image

After step by step combining each resulting image with a red-blue gradient (image2.png).
I used this command for vertical join with 10px indentation:

Code: Select all

convert image2.png 1.png -rotate 180 -background none -gravity South -smush 10 -rotate 180 +repage test.png
I noticed that in this case, the output images have slight differences in height. This is clearly seen when comparing the two images:

Image

I reassembled all the frames into an animation:

Image

If someone is interested the original images are here: https://www.sendspace.com/file/60dsez

But how can you replace, I got the shake effect of the pictures. I tried different ways to create animations, but the result was always the same.
I also tried putting a transparent background on the output images to bring them to the same size

Code: Select all

convert \( -size 111x156 xc:none \) test.png -gravity center -composite -compose Over +repage fin.png

But this did not lead to any distinctive changes.

How can I remove the jitter effect (the movement of the gradient up and down) when using the -smush method? to get something like this:

Image

This is the result I got when using this command:

Code: Select all

convert image2.png 1.png -background none +swap -append +repage test.png
but this method does not allow you to set the indentation between images and get the offset of layers as it does -smush

Thanks.