Bug report
I'm running into some problems when I try to read paletted JP2 (JPEG 2000 Part 1) images with pyvips. Here's an example of a paletted JP2:
palettedImage.jp2
I use this as input for this script:
import pyvips
imageIn = "palettedImage.jp2"
im1 = pyvips.Image.new_from_file(imageIn, access="sequential")
stats = im1.stats().tolist()
Result:
Traceback (most recent call last):
File "/home/johan/test/test-palette.py", line 7, in <module>
stats = im1.stats().tolist()
^^^^^^^^^^^
File "/home/johan/kb/digitalisering/tifftojp2/.venv/lib/python3.12/site-packages/pyvips/vimage.py", line 1353, in call_function
return pyvips.Operation.call(name, self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/johan/kb/digitalisering/tifftojp2/.venv/lib/python3.12/site-packages/pyvips/voperation.py", line 302, in call
raise Error(f'unable to call {operation_name}')
pyvips.error.Error: unable to call stats
jp2kload: Failed to decode all used components
jp2kload: Failed to decode the codestream in the JP2 file
For regular (non paletted) JP2s everything works as expected. Paletted TIFFs work fine as well (here's an example: poppies.tif)
Since Libvips uses OpenJPEG for JPEG 2000 decoding, I also tried decoding some paletted JP2s directly with OpenJPEG's opj_decompress tool (from v2.5.0 of libopenjp2-tools):
opj_decompress -i palettedImage.jp2 -o palettedImage-opj.tif
This works without problems, suggesting that the issue in LibVips is not caused by an inability of OpenJPEG to decode paletted JP2s, but rather by Libvips not interpreting the decoded image data correctly.
Environment
- OS: Linux Mint 22.3
- Vips: 8.15.1
Additional context
I'm using Python 3.12.3, with Pyvips installed in local mode, i.e. installed using:
sudo apt install libvips-dev --no-install-recommends
pip install pyvips
Bug report
I'm running into some problems when I try to read paletted JP2 (JPEG 2000 Part 1) images with pyvips. Here's an example of a paletted JP2:
palettedImage.jp2
I use this as input for this script:
Result:
For regular (non paletted) JP2s everything works as expected. Paletted TIFFs work fine as well (here's an example: poppies.tif)
Since Libvips uses OpenJPEG for JPEG 2000 decoding, I also tried decoding some paletted JP2s directly with OpenJPEG's opj_decompress tool (from v2.5.0 of libopenjp2-tools):
This works without problems, suggesting that the issue in LibVips is not caused by an inability of OpenJPEG to decode paletted JP2s, but rather by Libvips not interpreting the decoded image data correctly.
Environment
Additional context
I'm using Python 3.12.3, with Pyvips installed in local mode, i.e. installed using: