PIL PNG IOError

Ryan, Adam ARyan at CO.LINN.OR.US
Wed Mar 30 09:29:06 PST 2005


Howard & Sean,

Thanks for the input.  I'm using Howard's mapscript build and indeed turning
interlace off did solve the problem.

So, for PIL and PNG, I have added this to my pdf output script:

ofO = mapO.outputformat
ofO.setOption("INTERLACE","OFF")

Thanks for your continued help with my python endeavors.  Cheers,

Adam


> -----Original Message-----
> From: Sean Gillies [mailto:sgillies at frii.com]
> Sent: Wednesday, March 30, 2005 7:41 AM
> To: Adam Ryan
> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: PIL PNG IOError
>
>
> 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