I have some TGA files that cannot be read by the PIL TgaImagePlugin just
because they use the "id" field. This is easily fixed with the following
changes to PIL/TgaImagePlugin.py. Can someone add these changes to the next
release?
--- /Users/steve/Downloads/Imaging-1.1.7/PIL/TgaImagePlugin.py 2009-10-31
18:44:12.000000000 -0600
+++ TgaImagePlugin.py 2011-04-15 20:58:31.000000000 -0600
@@ -45,7 +45,7 @@
def _accept(prefix):
- return prefix[0] == "\0"
+ return True
##
# Image plugin for Targa files.
@@ -62,6 +62,8 @@
id = ord(s[0])
+ self.fp.read( id )
+
colormaptype = ord(s[1])
imagetype = ord(s[2])
@@ -72,7 +74,7 @@
self.size = i16(s[12:]), i16(s[14:])
# validate header fields
- if id != 0 or colormaptype not in (0, 1) or\
+ if colormaptype not in (0, 1) or\
self.size[0] <= 0 or self.size[1] <= 0 or\
depth not in (1, 8, 16, 24, 32):
raise SyntaxError, "not a TGA file"
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig