| 1 | = JPEG2000 utilities = |
| 2 | |
| 3 | == validate_jp2.py == |
| 4 | |
| 5 | This scripts analyzes the structure of a JPEG2000 and reports potential violations of application standards: errors JP2 boxes, erros JPEG2000 code stream, errors in GMLJP2, violations of Inspire Technical Guidelines on Orthoimagery. [[BR]] |
| 6 | |
| 7 | === Installation steps === |
| 8 | |
| 9 | GDAL binaries with Python bindings must be installed. [[BR]] |
| 10 | |
| 11 | (Windows) Let's begin with Python if not already done. Select one of the following packages depending on the wished architecture : [[BR]] |
| 12 | [https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi Windows x86 MSI installer] or [[BR]] |
| 13 | [https://www.python.org/ftp/python/2.7.9/python-2.7.9.amd64.msi Windows x86-x64 MSI installer] [[BR]] |
| 14 | |
| 15 | If not already available, the Python 'lxml' module, used for XML validation, must also be installed (from the console): [[BR]] |
| 16 | `python -m pip install lxml` (Windows) or [[BR]] |
| 17 | `pip install lxml` (Linux) |
| 18 | |
| 19 | (Windows) Then install GDAL core and the GDAL Python bindings : [[BR]] |
| 20 | 32-bit architecture : [[BR]] |
| 21 | [http://download.gisinternals.com/sdk/downloads/release-1500-gdal-mapserver/gdal-200-1500-core.msi Generic installer for the GDAL core components] [[BR]] |
| 22 | [http://download.gisinternals.com/sdk/downloads/release-1500-gdal-mapserver/GDAL-2.0.0.win32-py2.7.msi Installer for the GDAL python bindings (requires to install the GDAL core)] [[BR]] |
| 23 | 64-bit architecture : [[BR]] |
| 24 | [http://download.gisinternals.com/sdk/downloads/release-1500-x64-gdal-mapserver/gdal-200-1500-x64-core.msi Generic installer for the GDAL core components] [[BR]] |
| 25 | [http://download.gisinternals.com/sdk/downloads/release-1500-x64-gdal-mapserver/GDAL-2.0.0.win-amd64-py2.7.msi Installer for the GDAL python bindings (requires to install the GDAL core)] [[BR]] |
| 26 | |
| 27 | The following scripts must be downloaded in a directory : [[BR]] |
| 28 | http://svn.osgeo.org/gdal/trunk/autotest/pymod/gdaltest.py : contains routines to download and unzip packages[[BR]] |
| 29 | http://svn.osgeo.org/gdal/trunk/autotest/pymod/xmlvalidate.py : used for XML validation of GMLJP2 boxes[[BR]] |
| 30 | http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/validate_jp2.py : main script[[BR]] |
| 31 | |
| 32 | On Windows, launch the SDKShell and go to the directory where the scripts have been downloaded. [[BR]] |
| 33 | |
| 34 | A few tests rely on validate GMLJP2 boxes, which as XML content. Therefore the OGC schemas must be downloaded with : [[BR]] |
| 35 | `python xmlvalidate.py -download_ogc_schemas` |
| 36 | |
| 37 | Optional step: if you intend to validate a Orthoimagery XML document, you must also download the Inspire schemas with: [[BR]] |
| 38 | `python xmlvalidate.py -download_inspire_schemas` |
| 39 | |
| 40 | The validate_jp2.py script is now ready to be used. [[BR]] |
| 41 | |
| 42 | === How to use ? === |
| 43 | |
| 44 | The script takes a JPEG2000 filename as argument and options : |
| 45 | * -inspire_tg: asks to run checks related to the Inspire Technical Guidelines on Orthoimagery |
| 46 | * -oidoc name_of_a_oidoc.xml: XML document conforming with Inspire Orthoimagery GML application schema. |
| 47 | * -ogc_schemas_location: Path to directory with OGC schemas. Needed for GMLJP2 validation. If the OGC schemas have been downloaded as indicated above, validate_jp2.py will automatically find them. |
| 48 | * -expected_gmljp2: hint to indicate that a GMLJP2 box should be present |
| 49 | |
| 50 | If the script doesn't output any message, it means that all tests have successfully completed and the return code of the script will be 0 (for success). |
| 51 | |
| 52 | On Windows, launch the SDKShell and go to the directory where the scripts have been downloaded. [[BR]] |
| 53 | |
| 54 | Examples (files available in http://svn.osgeo.org/gdal/trunk/autotest/gdrivers/data/test_validate_jp2/): |
| 55 | * `python validate_jp2.py byte.jp2`: basic validation |
| 56 | * `python validate_jp2.py -inspire_tg byte.jp2`: basic validation + Inspire TG validation |
| 57 | * `python validate_jp2.py -inspire_tg -oidoc byte_oi.xml byte.jp2`: basic validation + Inspire TG validation + Check consistency with provided Orthoimagery description file |
| 58 | |
| 59 | === Validate a Orthoimagery XML document === |
| 60 | |
| 61 | `python xmlvalidate.py byte_oi.xml`: if the script doesn't output any message, it means that the XML document is valid |
| 62 | |
| 63 | == dump_jp2.py == |
| 64 | |
| 65 | This scripts displays the structure of a JPEG2000 file and enables to extract some information from it. [[BR]] |
| 66 | |
| 67 | === Installation steps === |
| 68 | |
| 69 | The installation steps of validate_jp2.py that cover Python, GDAL and GDAL Python bindings installation are sufficient for dump_jp2.py |
| 70 | |
| 71 | Iin addition, the following script must be also downloaded in a directory : [[BR]] |
| 72 | http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/dump_jp2.py [[BR]] |
| 73 | |
| 74 | === How to use ? === |
| 75 | |
| 76 | The script takes a JPEG2000 filename as argument and options : |
| 77 | * -dump_gmljp2 filename.xml: writes the content of the GMLJP2 box, if it exists, in the specified file |
| 78 | * -dump_crsdictionary filename.xml: Writes the content of the GML CRS dictionary box, if it exists, in the specified file |
| 79 | |
| 80 | On Windows, launch the SDKShell and go to the directory where the scripts have been downloaded. [[BR]] |
| 81 | |
| 82 | Examples: |
| 83 | * `python dump_jp2.py byte.jp2`: displays the structure of byte.jp2 in a XML format |
| 84 | * `python dump_jp2.py -dump_gmljp2 byte_gmljp2.xml byte.jp2`: extract the GMLJP2 box of byte.jp2 into byte_gmljp2.xml |
| 85 | * `python xmlvalidate.py byte_gmljp2.xml`: if the script doesn't output any message, it means that the XML document is valid |
| 86 | |
| 87 | == build_jp2_from_xml.py == |
| 88 | |
| 89 | This scripts builds a JPEG2000 file from an XML description of its structure. This script is not intended for widespread usage, |
| 90 | but more for developers to be able to generate non-conformant files for example. [[BR]] |
| 91 | |
| 92 | === Installation steps === |
| 93 | |
| 94 | The installation steps of dump_jp2.py that cover Python, GDAL and GDAL Python bindings installation are sufficient for build_jp2_from_xml.py |
| 95 | |
| 96 | In addition, the following script must be also downloaded in a directory : [[BR]] |
| 97 | http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/build_jp2_from_xml.py [[BR]] |
| 98 | |
| 99 | === How to use ? === |
| 100 | |
| 101 | The scripts takes 2 arguments: the first one is the name of a XML file (typically the output of dump_jp2 with manual modifications) and the second one is thae name of the output JPEG2000 file |
| 102 | |
| 103 | On Windows, launch the SDKShell and go to the directory where the scripts have been downloaded. [[BR]] |
| 104 | |
| 105 | Example (files available in http://svn.osgeo.org/gdal/trunk/autotest/gdrivers/data/test_validate_jp2/): |
| 106 | *` python build_jp2_from_xml.py byte_corrupted.xml byte_corrupted.jp2`: Builds byte_corrupted.jp2 frmo byte_corrupted.xml. Note that you must also have byte.jp2 next to byte_corrupted.xml since the later references the former |