I am posting a jpg image to my website (based on django), but I got "OSError in the URL XXXX / XXX of the broken data stream when reading the image file" when I use the pad to handle it.
this happens when running the code on the server:
if request.FILES: img = request.FILES['img'] ftype = img.content_type.split('/')[1] image = Image.open(img) imagefit = ImageOps.fit(image, (200, 200), Image.ANTIALIAS) fpath = MEDIA_ROOT+'avatar/'+user.username+'.'+ftype getpath = 'avatar/'+user.username+'.'+ftype imagefit.save(fpath,ftype)
and Traceback:
view: imagefit = ImageOps.fit(image, (200, 200), Image.ANTIALIAS) /PIL/ImageOps.py in fit: (leftSide, topSide, leftSide + cropWidth, topSide + cropHeight) /PIL/Image.py in crop: self.load() /PIL/ImageFile.py in load: raise_ioerror(e) /PIL/ImageFile.py in raise_ioerror: raise IOError(message + " when reading image file") message 'broken data stream' error -2 img <InMemoryUploadedFile: 169902.jpg (image/jpeg)> ftype 'jpeg' image <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1650x2550 at 0xB5CCBECC>
I use ubuntu 13.10 (32 bit), python3, pillow2.4.0, and I install libjpeg8-dev, python3-dev python3 render and reinstall the pillow (in virtualenv), but not fixed
source share