PIL PNG IOError

Sean Gillies sgillies at FRII.COM
Wed Mar 30 10:41:26 EST 2005


On Mar 29, 2005, at 3:58 PM, Adam Ryan wrote:

> Hello to all,
>
> I'm using Python Mapscript, ReportLab and PIL to generate PDF files on
> Windows XP.  I generate an image using mapscript, save it, and then
> insert
> it into my pdf 'canvas':
>
> Canvas.drawInlineImage(myfile,x,y,w,h)
>
> If my mapfile outputformat is gif, no problem - I get a nice pdf file.
>  But
> if my outputformat is png, I get an IOError:
>
> File "C:\python23\lib\site-packages\PIL\ImageFile.py", line 192, in
> load
> IOError: unknown error when reading image file
>
> Your thinking I'm posting to the wrong listserv right?  Well, if I take
> that png file and open it up in Micro$oft Paint and then save it, my
> routine then works without a problem.  So I compared the two png files
> (before and after saving with Paint) with gdalinfo but got identical
> results.  I did notice that there was a file size decrease after
> saving.
> But I don't know what else could be different about the files.  Any
> ideas?
>
> Here are two examples of file size reduction with output format:
>
> OUTPUTFORMAT
>   NAME png
>   DRIVER "GD/PNG"
>   MIMETYPE "image/png"
>   IMAGEMODE PC256
>   EXTENSION "png"
> END
>
> Reduction: 146kb to 137kb
>
> outputformat
>   name "png"
>   driver "GD/PNG"
>   imagemode "RGB"
>   mimetype "image/png"
>   extension "png"
> End
>
> Reduction: 272kb to 205kb
>
> Any sugestions would be grand.  Cheers to all,
>
> Adam
>
>

Adam,

Sorry, but I cannot reproduce this problem on Linux or on windows
(Python 2.3.3 and PIL 1.1.5).  PIL opens my mapscript PNG output just
fine.

Can you remind me of the source of your MapServer/mapscript software?

Sean


--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list