[Tilecache] Meta Tiled paletted images - PIL issue

Ivan Mincik ivan.mincik at gista.sk
Mon Oct 19 14:14:17 EDT 2009


On Mon, Oct 19, 2009 at 2:56 PM, Travis Kirstine
<traviskirstine at gmail.com> wrote:
> You can try getting the transparency value from the im.info dictionary
>
> im.save('out.png', 'PNG', transparency=im.info['transparency'])

Thanks for reply, but this is what I have already tried. 'im.info' is
containing just this: {'transparency': 0, 'Software': 'UMN
Mapserver'}.
I need transparency value for every palette color.

>
> 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