[Tilecache] Meta Tiled paletted images - PIL issue

Travis Kirstine traviskirstine at gmail.com
Mon Oct 19 08:56:06 EDT 2009


You can try getting the transparency value from the im.info dictionary

im.save('out.png', 'PNG', transparency=im.info['transparency'])

Regards

2009/10/19 Ivan Mincik <ivan.mincik at gista.sk>:
>
> I was looking for the reason, why we get corrupted image using
> Tilecache meta tiling with paletted images. (QUANTIZE_FORCE=ON,
> QUANTIZE_DITHER=OFF, QUANTIZE_COLORS=256 in UMN Mapserver).
>
> For others experiencing this problem I would like to note, that it
> could be a PIL issue in processing paletted images.
> I have tried following simple code (just opening and saving the image):
>
> #!/usr/bin/python
> import Image
>
> im = Image.open('test.png')
> print 'Image mode: ', im.mode
> print 'Info: ', im.info
> im.save('out.png', transparency=0)
>
> Output image is different than the original image. Why ? PIL seams to
> be loosing transparency value which is different for each color in PNG
> image.
> For example: 'test.png' is containing color 111 111 111 44 in palette.
> After opening and saving in PIL we get 111 111 111 255.
> I was trying also to extract palette from original image by using
> getpalette() function and put it back with putpalette(), but the
> result was the same.
>
> So, I think, we can not use meta tiling in paletted images because of
> PIL limits.
>
> For anybody wanting to look at this problem, You can download my test
> image here:
> http://gista.sk/dl/test.png
>
> Ivan
>
>
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache
>
>



-- 
Travis K.

Toronto, Canada
------------------------------------------------------------
"She knows there's no success like failure
and that failure's no success at all."
-Bob Dylan-
------------------------------------------------------------



More information about the Tilecache mailing list