[Tilecache] Mapserver AGG/PNG paletted image distorted when using
metatile due to limitation of PIL - works fine with pil-117-fastpng
SQ9MEV
groups at sq9mev.info
Sat Nov 19 02:20:31 EST 2011
W dniu 18.11.2011 20:42, SQ9MEV pisze:
> https://bitbucket.org/olt/pil-117-fastpng/
>
> TileCache needs to be patched a little to make things cooperating well,
> and it breaks Tilecache with standard PIL. pil-fastpng seems to be
> incompatible with standard PIL.
I'm not mastermind in PNG and PIL, but standard PIL sets
Image.info['transparency'] as int, while pil-fastpng set is as string
representation of tRNS aligned to 256 positions with 0xff, this patch
makes deciosion how to save subimage on that ground.
Works well, and (hope) does not break standard PIL.
Anyway, there's at least one drawback of using paletted PNGs:
32bit RGBA PNG empty tile size is 334B while png8 "P" mode paletted PNG
is 1768B. It's obvoius, as in paletted mode PNG contians PLTE chunk
(768B in my case) and tRNS 256B, altogether 1KB i my case (isn't it
compressed?).
--
Bartek
-------------- next part --------------
--- Layer.orig.py 2011-11-18 20:15:50.165063658 +0100
+++ Layer.py 2011-11-19 07:25:19.966185576 +0100
@@ -408,7 +408,8 @@
miny = maxy - self.size[1]
subimage = image.crop((minx, miny, maxx, maxy))
buffer = StringIO.StringIO()
- if image.info.has_key('transparency'):
+ ### Standard PIL sets transparency as int, while pil-fastpng sets it as string
+ if image.info.has_key('transparency') and isinstance(image.info['transparency'], int):
subimage.save(buffer, self.extension, transparency=image.info['transparency'])
else:
subimage.save(buffer, self.extension)
More information about the Tilecache
mailing list