pbfy0 / visvis

Automatically exported from code.google.com/p/visvis
Other
0 stars 0 forks source link

Colors of GIF images are off and non-consistent #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The colors of gif images are off compared to the images I input. Also, a color 
that is supposed to be constant can vary per frame.
I am not sure if this is a bug, or if it is inherent in gif images. I would've 
sent you an email but I couldn't find your address.

What steps will reproduce the problem?
-Download the attached images 1.png and 2.png

-Run the following code:
  import PIL, images2gif
  img1 = PIL.Image.open("1.png")
  img2 = PIL.Image.open("2.png")
  images2gif.writeGif("result.gif", [img1,img2], duration=1)

What is the expected output? What do you see instead?
I expect a 2-frame gif image, similar to the two png images I used.
In the result (result.gif, attached), the colors are off. When compared to the 
original pngs, the colors are very different (not as 'vibrant'). But also, 
there are differences between the two frames. For example, the red deer head is 
nearly brown in one frame.

What version of the product are you using? On what operating system?
I use images2gif.py from 1 september 2010, on python 2.7 (32 bits), on windows 
7 (64 bits)

Original issue reported on code.google.com by Nuntius.Marii@gmail.com on 20 Oct 2010 at 6:27

Attachments:

GoogleCodeExporter commented 9 years ago
On a sidenote: I tried making the gif in photoshop, and the result comes out 
much better, so it's not theoretically impossible. Perhaps PIL isn't good 
enough for this though...

Original comment by Nuntius.Marii@gmail.com on 20 Oct 2010 at 6:50

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Nuntius,

This is indeed a problem inherent to GIF images. Gif only supports 256 
different colors per frame, while PNG supports 24bit (1.677.7216) colors and an 
alpha channel.  

In response to your second message: that can be; selecting the right colors is 
not a simple process and several approaches are possible. I'm not surprised 
that photoshop is better at it than PIL :)

Recent improvement were made to the algorithm (of images2gif.py) such that it 
selects a color table for each frame, which significantly improves results for 
most image sequences, but can indeed result in inconsistent colors between 
frames.

So although its widely available, gif isn't such a great standard. I'd suggest 
using swf, which more or less wraps png images in a movie. It also has much 
better compression that gif (zlib instead of RLE).

I'm marking this issue invalid, because it's not a bug. If you have any more 
questions, please e-mail me at almar.klein at gmail dot com.

Original comment by almar.klein@gmail.com on 20 Oct 2010 at 6:59