Page 1 of 1

composite over gif

Posted: 2016-08-18T19:49:39-07:00
by alealvaro
Hello! Please I need help with this:

I have a gif image, and I need to composite over that Image a png. How can I do that?

I tried to composite right over the gif, like:

Code: Select all

composite -geometry +519+0 overlay.png my.gif test.gif
But only put the png in the first frame.

Then I tried:

Code: Select all

convert -coalesce my.gif out%05d.png
In order to have all the gif's frames separately, thinking I could try to put the png over each one and then generate the gif again, but I couldn't find how to do that :(

What do you think? Which would be the best approach and how can I handle it?

Thanks in advance!

Re: composite over gif

Posted: 2016-08-18T20:04:05-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your your images.

See viewtopic.php?f=1&t=9620

See the top-most post in this forum README FIRST at: -layers composite at http://www.imagemagick.org/Usage/anim_mods/

Example:

GIF Animation:
Image

PNG:
Image

Code: Select all

convert hue_rotation_animation.gif -coalesce null: cyclops.png -gravity center -layers composite result.gif
Image

Re: composite over gif

Posted: 2016-08-18T20:17:09-07:00
by alealvaro
Thanks for your answer.

This is the data:
Version: ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org (running on CentOS)
Animated gif: http://stream1.gifsoup.com/view1/473665 ... -3-a-o.gif
PNG overlay: http://koti.tamk.fi/~c2nsaijo/insurance ... c_link.png

I need to the PNG overlay over the animated gif, aligned to the right. Thanks in advance!

Re: composite over gif

Posted: 2016-08-18T20:23:18-07:00
by GeeMack
alealvaro wrote:I need to the PNG overlay over the animated gif, aligned to the right. Thanks in advance!
Something like this should work...

Code: Select all

convert bugatti-3-a-o.gif null: -gravity east sidepic_link.png -layers composite bugatti-new.gif

Re: composite over gif

Posted: 2016-08-18T20:28:35-07:00
by alealvaro
Thanks! That helped me to make it works!!

Just one more question, I tried with this images:

(you could find them in this Google drive folder) https://drive.google.com/drive/folders/ ... sp=sharing

There are a gif and a png, I tried to generate the new gif with this command:

Code: Select all

convert my_image.gif -geometry +519+0 -coalesce null: hotlist-overlay.png -layers composite result.gif
It worked! But if you check the result.gif in the same folder, some pixels are weird. Is there any chance to improve this cli and make the result gif better without those dots? Thanks again!

Re: composite over gif

Posted: 2016-08-18T20:48:49-07:00
by fmw42
I think you should specify -geometry and/or -gravity after the hotlist-overlay.png. So try either of these

Code: Select all

convert my_image.gif -coalesce null: hotlist-overlay.png -geometry +519+0 -layers composite result1.gif

Code: Select all

convert my_image.gif -coalesce null: hotlist-overlay.png -gravity east -layers composite result2.gif

Re: composite over gif

Posted: 2016-08-18T20:52:40-07:00
by alealvaro
You're right, that order for geometry and gravity are the right one, but, I'm still having those weird dots in the result image. Is there anything else I could try? Could be these some kind of problem with the amount of colors the gif has?

Re: composite over gif

Posted: 2016-08-18T20:57:00-07:00
by fmw42
I don't see any weird pixels. Can you explain further?

But if you combine a gif animation with the png, the color map changes for each frame due to the colors in the overlay image. So it is possible that some colors are slightly different. GIF only allows 256 colors per frame. For example if you had no red in the original animation, now you have to remove some color from the animation to make room for the red color of the png.

Re: composite over gif

Posted: 2016-08-19T05:31:36-07:00
by alealvaro
Thanks for the explanación!

I mean for example in the upper left cornet the sky in the post lose some quality. Or in the upper right córner, just before the overlay, the are some dancing píxels in the cortain. Those weird píxels are not in the original gif. Is there any way to avoid that?

Thanks again!

Re: composite over gif

Posted: 2016-08-19T09:54:27-07:00
by fmw42
Adding +dither to turn off dithering when regenerating the gif colortables seems to help mitigate it. I do not think you can avoid it due to the reason I gave about making room for other colors in the limited 256 color colortable.

Code: Select all

convert my_image.gif -coalesce null: hotlist-overlay.png -gravity east +dither -layers composite result3.gif