Package: jpylyzer
jpylyzerAboutJpylyzeris a JP2(JPEG 2000 Part 1)image validator and properties extractor. Its development was partially supported by theSCAPEProject. The SCAPE project is co-funded by the European Union under FP7 ICT-2009.4.1 (Grant Agreement number 270137).Jpylyzer homepagePlease visit the jpylyzer homepage for links to the most recent package downloads (Debian packages and Windows binaries), and a User Manual which documents all aspects of the software:https://jpylyzer.openpreservation.org/CI StatusTravis-CIOPF JenkinsUsing jpylyzer from the command lineCallingjpylyzerin a command window without any arguments results in the following helper message:usage: jpylyzer [-h] [--format FMT] [--mix {1,2}] [--nopretty]
            [--nullxml] [--recurse] [--packetmarkers] [--verbose]
            [--version] jp2In [jp2In ...]Positional argumentsArgumentDescriptionjp2Ininput image(s), may be one or more (whitespace-separated) path expressions; prefix wildcard (*) with backslash (\) in LinuxOptional argumentsArgumentDescription[-h, --help]show help message and exit[--format FMT]validation format; allowed values arejp2(JPEG 2000 Part 1, used by default),j2c(Part 1 codestream),jph(JPEG 2000 Part 15 / High Throughput JPEG 2000) andjhc(Part 15 codestream)[--mix {1,2}]report additional output in NISO MIX format (version 1.0 or 2.0)[--nopretty]suppress pretty-printing of XML output[--nullxml]extract null-terminated XML content from XML and UUID boxes(doesn't affect validation)[--recurse, -r]when analysing a directory, recurse into subdirectories[--packetmarkers]Report packet-level codestream markers (plm, ppm, plt, ppt)[--verbose]report test results in verbose format[-v, --version]show program's version number and exitOutputOutput is directed to the standard output device (stdout).ExamplesValidate JP2 image:jpylyzer rubbish.jp2 > rubbish-jp2.xml`Validate JPEG 2000 Part 1 codestream:jpylyzer --format j2c rubbish.j2c > rubbish-j2c.xml`Validate JPH (High Throughput) image:jpylyzer --format jph rubbish.jph > rubbish-jph.xml`Validate JPEG 2000 Part 15 (High Throughput) codestream:jpylyzer --format jhc rubbish.jhc > rubbish-jhc.xml`In the above examples, output is redirected to the output files ‘rubbish-???.xml’. By defaultjpylyzer’s XML is pretty-printed, so you should be able to view the file using your favourite text editor. Alternatively use a dedicated XML editor, or open the file in your web browser.Output formatThe output file contains the following top-level elements:OnetoolInfoelement, which contains information aboutjpylyzer(its name and version number)One or morefileelements, each of which contain information about about the analysed filesIn turn, eachfileelement contains the following sub-elements:fileInfo: general information about the analysed filestatusInfo: information about the status ofjpylyzer's validation attemptisValid: outcome of the validationtests: outcome of the individual tests that are part of the
validation process (organised by box)properties: image properties (organised by box)propertiesExtension: wrapper element for NISOMIXoutput (only if the--mixoption is used)warnings: reported warningsUsing jpylyzer as a Python moduleInstead of usingjpylyzerfrom the command-line, you can also import
it as a module in your own Python programs. To do so, install jpylyzer
withpip. Then importjpylyzerinto your code by adding:fromjpylyzerimportjpylyzerSubsequently you can call any function that is defined injpylyzer.py.
In practice you will most likely only need thecheckOneFilefunction.
The following minimal script shows how this works:#! /usr/bin/env python3fromjpylyzerimportjpylyzer# Define JP2myFile="/home/johan/jpylyzer-test-files/aware.jp2"# Analyse with jpylyzer, result to Element objectmyResult=jpylyzer.checkOneFile(myFile)# Return image height valueimageHeight=myResult.findtext('./properties/jp2HeaderBox/imageHeaderBox/height')print(imageHeight)Here,myResultis anElementobject that can either be used directly,
or converted to XML using theElementTreemodule[^3].For validation a raw JPEG 2000 codestreams, call thecheckOneFilefunction with the additionalvalidationFormatargument, and set it toj2c:# Define CodestreammyFile="/home/johan/jpylyzer-test-files/rubbish.j2c"# Analyse with jpylyzer, result to Element objectmyResult=jpylyzer.checkOneFile(myFile,'j2c')Steps in preparing a jpylyzer releaseSee instructions here