jp2_remediator
A Python module to validate jp2 images:
- reads the bytes of a jp2 file or directory of files or S3 bucket
- looks for presence of ICC profile
- maps and validates curv values according to the ISO/IEC 15444-1:2019 (E) and ICC.1:2022 Specifications
- corrects values where the rTRC/gTRC/bTRC tag size in the Tag table structure (ICC.1:2022 Table 24 tag size) is not the same as the count value (gamma, where n == 1) in the curveType encoding (ICC.1:2022 Table 35, n value)
- flag and (optionally) log values where the count value n != 1 for future review
Installation
pip install jp2_remediator
python3 -m pip install jp2_remediator
pip install jp2_remediator==NN.NN.NN (version number)
Usage
python3 src/jp2_remediator/main.py -h
usage: main.py [-h] {file,directory,bucket} ...
JP2 file processor
options:
-h, --help show this help message and exit
Input source:
{file,directory,bucket}
file Process a single JP2 file
directory Process all JP2 files in a directory
bucket Process all JP2 files in an S3 bucket
Process one file
python3 src/jp2_remediator/main.py file tests/test-images/7514499.jp2
python3 src/jp2_remediator/main.py file tests/test-images/481014278.jp2
Process directory
python3 src/jp2_remediator/main.py directory tests/test-images/
Process all .jp2 files in an S3 bucket:
python3 src/jp2_remediator/main.py bucket remediation-folder
Process only files with a specific prefix (folder):
python3 src/jp2_remediator/main.py bucket remediation-folder --prefix testbatch_20240923`
Run tests
Run integration tests
pytest src/jp2_remediator/tests/integration/
Run unit tests
pytest src/jp2_remediator/tests/unit/
Docker environment
Build Docker image
./bin/docker-build.sh
Run Docker container as executable
./bin/docker-run.sh -h
Development environment
uv sync
export PYTHONPATH="${PYTHONPATH}:src"
uv run python src/jp2_remediator/main.py -h
Publishing to PyPI
Add the following variable to your .env:
UV_PUBLISH_TOKEN=pypi-<token>
Set the version number in pyproject.toml to the version you wish to publish.
Run the following commands:
rm -rf dist/
uv build
uv publish
If you get a publish error, the following commands will set your .env variables into the shell and should work:
set -a
source .env
set +a
uv publish
Metadata
Release files for jp2_remediator 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jp2_remediator-1.2.1.tar.gz | 21.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jp2_remediator-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.3 kB
Release files / jp2_remediator-1.2.1.tar.gz
| Download URL | jp2_remediator-1.2.1.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ce4fd0561b457e593d94e28176f6a63275ef77094b8bfc3f1d076d290e56690
|
|
BLAKE2b-256 checksum How to use checksums |
10ee7e945978fe4b3b721a327a08bc29c33b6265625228b11e384ade028a8d9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.10
|
Release files / jp2_remediator-1.2.1-py3-none-any.whl
| Download URL | jp2_remediator-1.2.1-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0871426ad9a366bb28a7a2a0dfb93f67efca82ce488f0c3b85b4bed85485f61b
|
|
BLAKE2b-256 checksum How to use checksums |
1354de75e5d693b5f6ec6af9dd09a5502bbf8cff49494a2037270c6e8fce10da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.10
|