I have the same image, one of them is the original one stored on my machine, another one uploaded to the azure blob storage and downloaded back to my local machine. Here is a piece of code (Python 3.6.3, Pillow-SIMD 4.3.0post0, libjpeg-turbo, ubuntu 17.10/alpine docker container):
image_stream = open('src/app/resize/resizer/corrupted_blob.jpg', 'rb')
image = Image.open(image_stream)
image.load()
When the interpreter hits the .load method exception is raised: OSError: image file is truncated (6 bytes not processed)
so it happens only with corrupted_blob.jpg
, corrupted_original.jpg
is loaded and displayed correctly.
I know that the first assumption would be 'here is something happened during uploading', but either a browser or windows/ubuntu image viewer or another piece of software which renders images handle both of the images correctly. So there is something with pillow or with underlying libjpeg.
I have tried to use ImageFile.LOAD_TRUNCATED_IMAGES = True
but all I get is a black image -_-
Please help!