[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
Fri Nov 18 14:42:36 EST 2011


Hi All

I spent last day struggling with crippled images produced by tilecache 
run with mapscript Mapserver bindings. It was hard to find out what's 
happening due to quite complicated toolchain (its all run via django).

The essence of my problem is standard PIL (1.1.7) which does not cope to 
well with paletted PNG. Subimages cropped from metatile are crippled then.

I've found discussion about this issue:
< 
http://osgeo-org.1803224.n2.nabble.com/Meta-Tiled-paletted-images-PIL-issue-td3848319.html 
 >

I didn't wanto to stay with 32 bit PNG nor turn metatiling off due to 
edge effects. So... I've found this fork of PIL, which works well with 
paleted PNG:

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.

Any better idea how to make things working as expected?


-- 
Bartek
-------------- next part --------------
--- Layer.orig.py       2011-11-18 20:15:50.165063658 +0100
+++ Layer.py    2011-11-18 20:07:44.397332495 +0100
@@ -408,10 +408,11 @@
                 miny = maxy - self.size[1]
                 subimage = image.crop((minx, miny, maxx, maxy))
                 buffer = StringIO.StringIO()
-                if image.info.has_key('transparency'): 
-                    subimage.save(buffer, self.extension, transparency=image.info['transparency'])
-                else:
-                    subimage.save(buffer, self.extension)
+                #if image.info.has_key('transparency'): 
+                #    subimage.save(buffer, self.extension, transparency=image.info['transparency'])
+                #else:
+                #    
+                subimage.save(buffer, self.extension)
                 buffer.seek(0)
                 subdata = buffer.read()
                 x = metatile.x * self.metaSize[0] + i



More information about the Tilecache mailing list