O
O
Onthar2012-04-18 19:32:06
Python
Onthar, 2012-04-18 19:32:06

Python and overlaying a watermark on an animated GIF?

The first thing I tried was to use PIL. As it turned out, saving an uncorrupted image is not so easy.

imbase = Image.open('/path/to/img.gif')<br>
imwater = Image.open('/path/to/watermark.png')<br>
frames = [frame.copy() for frame in ImageSequence.Iterator(imbase)]<br>
frames.reverse()<br>
for frame in frames:<br>
    frame.paste(imwater,(imbase.size[0]-imwater.size[0],imbase.size[1]-imwater.size[1]),imwater)<br>
images2gif.writeGif('/path/to/new.gif', frames)<br>

I used images2gif for saving . The output from any gif is something like this .
Numerous attempts to cure this with recipes from stackoverflow have been unsuccessful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Onthar, 2012-04-25
@Onthar

PIL had to be abandoned in favor of PythonMagickWand (binding to the ImageMagick API). There were attempts to use pgmagick, but as it turned out the documentation was outdated. The code

A
Anatoly, 2012-04-18
@taliban

Are the pictures themselves okay? Before saving with animation. Maybe somewhere before the animation everything deteriorates?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question