GIF89A and PIL

Stephen Hansen apt.shansen at gmail.invalid
Sat Mar 27 02:45:54 CET 2010

Hi, all.

Is it possible to get PIL to save GIF's in GIF89A format, instead of 
GIF87A? If not, are there any decent other image libraries out there 
that anyone's familiar with? The only one I could find was 
PythonMagick, which seems completely undocumented. Or I'm blind.


But the problem is, I have a nice, small little 72 byte GIF89A file, 
that I want to do some slight tweaking on and then re-save. I noticed 
that even if I completely skipped the tweaking step and -just- saved, 
it exploded into a 919 byte GIF87A file. And in this context, bytes 
really, really matter. I picked GIF over PNG because the same file in 
PNG was 120 bytes :)

I'm not an expert on graphics, so I don't actually know for certain if 
its the fact that PIL is saving in GIF87A format that's causing the 
size to explode, it might just be that PIL is doing.. Something Weird 
when it saves it as a GIF, too.

To demonstrate:

>>> f = open('../tiles/BaseTemplate.gif', 'rb')
>>> d1 =
>>> len(d1)
>>> d1

im ='../tiles/BaseTemplate.gif')
>>> import cStringIO
>>> cfp = cStringIO.StringIO()
>>>, format="gif")
>>> d2 =
>>> d2
>>> len(d2)


... p.s: change the ".invalid" to ".com" in email address to reply privately.

More information about the Python-list mailing list