Skip to content

harvard-lts/jp2_remediator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fcfd914 · Jan 20, 2025

History

35 Commits
Nov 15, 2024
Jan 17, 2025
Jan 20, 2025
Oct 17, 2024
Nov 15, 2024
Dec 18, 2024
Aug 9, 2024
Dec 18, 2024
Nov 15, 2024
Nov 15, 2024

Repository files navigation

jp2_remediator

PyPI version

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

jp2_remediator on PyPI

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

python3 -m venv myenv
source myenv/bin/activate
export PYTHONPATH="${PYTHONPATH}:src"
pip install -r requirements.txt

python src/jp2_remediator/main.py -h