1

I find the similar issue here and the solution works. But I don't want the grey shade for lost/truncated bytes. I would more likely appreciate proper cause of that problem.

My attempt:

from PIL import Image
in_file = open("/root/1735221450770222881.jpg", "rb")    
data = in_file.read()
print len(data)

im = Image.open(StringIO.StringIO(data))
print type(im)

thumb_io = StringIO.StringIO()

try:
    out = im.load()
except IOError as e:
    pass

Traceback:

Traceback (most recent call last): File "test_image.py", line 25, in out = im.resize((3200, 3200), Image.LANCZOS) File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 1557, in >resize

self.load() File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 232, >in load "(%d bytes not processed)" % len(b)) IOError: image file is truncated (14 bytes not processed)

N.B. This is not a generic problem. For most of my image, no error raises. Eventually, I want to resize the image, for some it succeeds and for some a grey layer added at the bottom.

Community
  • 1
  • 1
Ahsanul Haque
  • 10,676
  • 4
  • 41
  • 57

0 Answers0