title: PIL "IOError: image file truncated" with big images
body: <p>I think this problem is not Zope-related. Nonetheless I'll explain what I'm trying to do:</p>
  
  <p>I'm using a PUT_factory in Zope to upload images to the ZODB per FTP. The uploaded image is saved as a Zope Image inside a newly created container object. This works fine, but I want to resize the image if it exceeds a certain size (width and height). So I'm using the thumbnail function of PIL to resize them i.e. to 200x200. This works fine as long as the uploaded images are relatively small. I didn't check out the exact limit, but 976x1296px is still ok.</p>
  
  <p>With bigger pictures I get: </p>
  
  <pre><code>Module PIL.Image, line 1559, in thumbnail
  Module PIL.ImageFile, line 201, in load
  IOError: image file is truncated (nn bytes not processed).
  </code></pre>
  
  <p>I tested a lot of jpegs from my camera. I don't think they are all truncated.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if img and img.meta_type == 'Image':
    pilImg = PIL.Image.open( StringIO(str(img.data)) )
  elif imgData:
    pilImg = PIL.Image.open( StringIO(imgData) )
  
  pilImg.thumbnail((width, height), PIL.Image.ANTIALIAS)
  </code></pre>
  
  <p>As I'm using a PUT_factory, I don't have a file object, I'm using either the raw data from the factory or a previously created (Zope) Image object.</p>
  
  <p>I've heard that PIL handles image data differently when a certain size is exceeded, but I don't know how to adjust my code. Or is it related to PIL's lazy loading?</p>