Skip to content

OSError: broken data stream when using OpenJPEG 2.5.2 #8327

Closed
@iivvaall

Description

selfie-min.jpeg.zip

pillow 10.3.0 and 10.4.0 installed from pip fails to open jpeg from this zip archive
pillow 10.2.0 works fine

pillow 10.3.0 and 10.4.0 installed from git also work fine

What did you do?

open jpeg from zip archive

What did you expect to happen?

jpeg is loaded successfully

What actually happened?

pillow 10.3.0 and 10.4.0 installed from pip raises OSError

steps to reproduce

this command

docker run --rm -i -v ./selfie-min.jpeg.zip:/selfie-min.jpeg.zip python /bin/bash -ex <<EOF
unzip /selfie-min.jpeg.zip
pip install pillow==10.3.0
python -m PIL.report
python -c 'from PIL import Image; Image.open("selfie-min.jpeg").load()'
EOF

raises

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.12/site-packages/PIL/Jpeg2KImagePlugin.py", line 313, in load
    return ImageFile.ImageFile.load(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PIL/ImageFile.py", line 310, in load
    raise _get_oserror(err_code, encoder=False)
OSError: broken data stream when reading image file

while this code

docker run --rm -i -v ./selfie-min.jpeg.zip:/selfie-min.jpeg.zip python /bin/bash <<EOF
set -ex
unzip /selfie-min.jpeg.zip
pip install git+https://github.com/python-pillow/Pillow.git@10.3.0
python -m PIL.report
python -c 'from PIL import Image; Image.open("selfie-min.jpeg").load()'
echo image loading successed
EOF

works fine

What are your OS, Python and Pillow versions?

compilled from source

--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.3.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.12.1
--- LITTLECMS2 support ok, loaded 2.14
--- WEBP support ok, loaded 1.2.4
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 2.1.5
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.0
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.13
--- LIBTIFF support ok, loaded 4.5.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------

installed from pip

--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.3.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.3.2
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.2
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.13
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.8, harfbuzz 8.4.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions