[Image-SIG] buffer overrun loading some TGAs

Adam Pletcher adam at volition-inc.com
Wed Jan 2 22:52:54 CET 2008


Hello.  I searched the archives for this but came up empty.

I'm getting a "image buffer overrun error", when doing the first
operation on certain image files.  Specifically in \PIL\ImageFile.py,
line 207, PIL 1.1.6.

It appears limited to certain RGBA Targa images.  The odd part is, if
the operation is immediately run again it works fine with no errors.

For example:

   >>> img = Image.open(r'D:\temp\hud_sheet_04.tga')
   >>> img2 = img.convert('RGB')
   Traceback (most recent call last):
     File "<pyshell#13>", line 1, in <module>
       img2 = img.convert('RGB')
     File "C:\Python25\lib\site-packages\PIL\Image.py", line 653, in
convert
       self.load()
     File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 207, in
load
       raise IOError(error + " when reading image file")
   IOError: image buffer overrun error when reading image file
   >>> img2 = img.convert('RGB')
   >>>

Am I missing something?  Is there something non-standard about these
image files?  I'm guessing so, but I can't nail it down.  I've
successfully loaded them in in various programs with no issues.  It
appears I can get PIL to load them by re-saving them in certain
programs, even though no other apps give me load errors.

I posted one culprit image file in case someone is able to test/confirm
for me:
http://www.adamsarcade.com/misc/hud_sheet_04.tga

I can put a second operation attempt inside a try/except, but I'm
preparing this script for a talk I'm giving and I'd like to avoid that
kind of hackery if possible.

Any suggestions appreciated.

--
Adam Pletcher
Technical Art Director
Volition/THQ



More information about the Image-SIG mailing list