Skip to content

Inconsistent behavior opening truncated JPEG file #2977

@elbaro

Description

@elbaro

What did you do?

from PIL import Image
import numpy as np
a=Image.open('aa.jpg')
b1=np.array(a)
b2=np.array(a)

What did you expect to happen?

b1.shape == b2.shape == (H,W,3)

What actually happened?

Surprisingly, b1.shape == () and b2.shape == (H, W, 3).

b1:
array(<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=2000x2000 at 0x7FCD...48>, dtype=object)

I have a large RAM available (>50G).
This is consistently reproduced for a specific image file:
https://farm5.staticflickr.com/4360/36444958735_32c0410b64_o.jpg

What versions of Pillow and Python are you using?

5.1.0.dev0 && 4.3.0 (pip version)
Python 3.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.NumPy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions