IIRC, PIL does not support 8bit pngs with transparency, so writing it to a file won't help. If you need alpha, you'll have to stick with 32bit pngs.
-- thomas On Fri, Sep 7, 2012 at 3:35 PM, Jelmer Baas <b...@speerit.nl> wrote: > Hi All, > > I've been testing today in Python, trying to get a MapScript imageObj into an > python Image object. This works via the following code: > > > map.transparent = MS_ON > map.selectOutputFormat('png8') > map.outputformat.imagemode = MS_IMAGEMODE_RGBA > map.outputformat.transparent = MS_ON > > img = map.draw() > mem_png = StringIO.StringIO(img.saveToString()) > _img = Image.open(mem_png) > > However, the _img file lost its transparency, even though it's still (or > again) PNG. There MUST be a better way of getting the PNG file into PIL, > right? Something besides writing it to a tempfile, opening it, and deleting > it? > > On a side note, I only use this rendered image temporarily, I only need to > cut it up in smaller bits and return those to my client. So if there's some > sort of format that supports transparcency but without the PNG compression > overhead, that would be even better! > > Regards, > Jelmer Baas > > _______________________________________________ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/mapserver-users _______________________________________________ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users