large-image-source-openjpeg

raw JSON →
1.34.1 verified Sat May 09 auth: no python

An OpenJPEG-based tile source for the large-image library, enabling efficient reading of JPEG2000 (JP2) images. Current version 1.34.1. Release cadence is irregular, tied to the large-image monorepo.

pip install large-image-source-openjpeg
error ModuleNotFoundError: No module named 'large_image_source_openjpeg'
cause The package is not installed or is installed under a different environment.
fix
Run 'pip install large-image-source-openjpeg' in the correct Python environment.
error glymur.codestream.Jp2kRuntimeError: Failed to read JP2 file
cause The file is corrupt or uses an unsupported JP2 feature (e.g., 16-bit precision, certain color spaces).
fix
Check file validity; convert to a supported format (e.g., TIFF) using a tool like ImageMagick.
error OSError: libopenjp2.so.7: cannot open shared object file
cause The system library libopenjp2 is not installed.
fix
Install it via system package manager: sudo apt-get install libopenjp2-7 (Debian/Ubuntu) or sudo yum install openjpeg2 (RHEL/CentOS).
gotcha The underlying glymur library requires libopenjp2 to be installed on the system. Installing via pip alone will fail if the C library is missing.
fix Install libopenjp2 via system package manager (e.g., apt install libopenjp2-7, yum install openjpeg2).
deprecated As of large-image 1.34.0, Python 3.9 support was dropped. This source now requires Python >=3.10.
fix Upgrade Python to 3.10 or later.
gotcha The source does not support all JP2 features; it may fail on images with certain color spaces or resolution reductions.
fix Verify the image opens correctly; consider using large-image-source-tiff for more complex cases.

Open a JP2 file and read its metadata and a tile at level 0.

from large_image_source_openjpeg import OpenjpegTileSource

ts = OpenjpegTileSource('path/to/input.jp2')
print(ts.getMetadata())
tile = ts.getTile(0, 0, 0)
print(tile.shape)