Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image.open() fails for JPEG 2000 with embedded ICC profile #3556

Closed
hajimen opened this issue Jan 7, 2019 · 4 comments · Fixed by #5654
Closed

Image.open() fails for JPEG 2000 with embedded ICC profile #3556

hajimen opened this issue Jan 7, 2019 · 4 comments · Fixed by #5654
Labels
Anaconda Issues with Anaconda's Pillow JPEG
Projects

Comments

@hajimen
Copy link

hajimen commented Jan 7, 2019

What did you do?

I tried to open a JPEG 2000 file here.
(https://github.com/openpreserve/format-corpus/blob/master/jp2k-test/icc/balloon_eciRGBv2_aware.jp2)

The image can be opened by IrfanView, GIMP and read by ImageMagick.

What actually happened?

OSError: cannot identify image file 'balloon_eciRGBv2_aware.jp2'

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: Python 3.6.6 :: Anaconda custom (64-bit)
  • Pillow: 5.4.0 conda-forge
bim = Image.open('balloon_eciRGBv2_aware.jp2')
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-7-9e62275bed11> in <module>()
----> 1 bim = Image.open('balloon_eciRGBv2_aware.jp2')

~\Anaconda3-5\lib\site-packages\PIL\Image.py in open(fp, mode)
   2685         warnings.warn(message)
   2686     raise IOError("cannot identify image file %r"
-> 2687                   % (filename if filename else fp))
   2688 
   2689 #

OSError: cannot identify image file 'balloon_eciRGBv2_aware.jp2'
@radarhere
Copy link
Member

radarhere commented Jan 7, 2019

The error is being caused by struct.error: unpack requires a bytes object of length 8 at

lbox, tbox = struct.unpack('>I4s', hio.read(8))

The code would normally have broken out of the loop before that. This section of the code is trying to find the image mode. However, it does not handle the case where meth is 2, which signifies the Restricted ICC profile.

@radarhere radarhere added the JPEG label Mar 4, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@zoj613
Copy link

zoj613 commented May 7, 2020

whats the progress on this?

@KirschbaumP
Copy link

Any news?

@radarhere
Copy link
Member

I've created PR #5654 to resolve this.

Pillow automation moved this from In progress to Closed Aug 24, 2021
@aclark4life aclark4life added the Anaconda Issues with Anaconda's Pillow label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anaconda Issues with Anaconda's Pillow JPEG
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

5 participants