PIL and jpg -> png conversion

Fredrik Lundh fredrik at pythonware.com
Tue Nov 18 08:55:06 EST 2003


Vincent Raaijmakers wrote:

> s = StringIO()
> image.save(s,'PNG')
> return s.getvalue()

> Unfortunately, this seems only to work for GIF and JPEG, but not for PNG.
> As a test I try to reconvert the file output to an image again but the
> image.verify() throws an fp.seek.tile error. This only happens with PNG files.

is this what you get?

Traceback (most recent call last):
  File "PngImagePlugin.py", line 280, in verify
    self.fp.seek(self.tile[0][2] - 8)
AttributeError: 'None' object has no attribute 'seek'

if that's the case, the problem is in "verify", not in the file.

the "verify" method is only guaranteed to work if you call it on a "freshly"
opened image; if you load the image (or do anything that causes the image
to be loaded), the result is undefined.

(I agree that the error message could be slightly improved ;-)

</F>








More information about the Python-list mailing list