An patch to support semi-transparent PNG8
张挺 <[email protected]>
| Newsgroups | gmane.comp.python.image |
|---|---|
| Message-ID | <[email protected]> |
according to PNG Specification, png8 images(with type 3) should support semi transparent images, with tRNS chunk, but current version of PIL does not handle it correctly two simple patch can make PIL read this type of file correctly. I've attached the patch file. more efforts are needed to support saving png of this type. PS: is there a bug tracing system for PIL? _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
Image.py.patch
(application/octet-stream, 403 B)
615c615,620 < self.im.putpalettealpha(self.info["transparency"], 0) --- > trans = self.info["transparency"] > if type(trans) is int: > self.im.putpalettealpha(self.info["transparency"], 0) > else: > for i, a in enumerate(trans): > self.im.putpalettealpha(i, ord(a))
PngImagePlugin.py.patch
(application/octet-stream, 313 B)
246,248c246,249 < i = string.find(s, chr(0)) < if i >= 0: < self.im_info["transparency"] = i --- > #i = string.find(s, chr(0)) > #if i >= 0: > # self.im_info["transparency"] = i > self.im_info["transparency"] = s