ImageMagick's JPEG-2000 image formats, JP2 and JPC, accept a plethora of encoding options as detailed below. As an example, suppose you are interested in these options:
- Code blocks are 64 samples in width and 32 samples in height.
- No multicomponent transform.
- 4 resolution levels for each component.
- Compression is lossy at 64:1.
Use this command to convert a JPEG-2000 image to the PNG image format:
jp2-to-png.sh
$ magick wizard.jp2 wizard.png
Let's convert a JPEG image to a lossless JPEG-2000 image:
jpg-to-lossless-jp2.sh
$ magick wizard.jpg -quality 0 wizard.jp2
Here we extract an area from the image:
extract-area.sh
$ magick 'wizard.jp2[640x480+0+0]' wizard.png
Extract a particular tile from the image:
extract-tile.sh
$ magick 'wizard.jp2[2]' wizard.png
Specify a subsampling factor:
subsampling-factor.sh
$ magick wizard.png -colorspace YUV -sampling-factor 2:2 wizard.jp2
Save a tiled JPEG-2000 image:
save-tiled.sh
$ magick wizard.png 'wizard.png[512x512]'
Write a digital Cinema 4K profile compliant codestream:
cinema-4k.sh
$ magick wizard.png -resize 4096x2160! -depth 12 wizard.jp2
Here is a complete list of JPEG-2000 decoding options:
| Option | Description |
|---|---|
jp2:quality-layers=<x> |
Set the maximum number of quality layers to decode. |
jp2:reduce-factor=<x> |
Set the number of highest resolution levels to be discarded. |
Here is a complete list of JPEG-2000 encoding options:
| Option | Description |
|---|---|
jp2:number-resolutions=<x> |
Number of resolutions to encode. |
jp2:quality=<x>,<x>,... |
Set the quality layer PSNR, given in dB. The order is from left to right in ascending order. The default is a single lossless quality layer. |
jp2:rate=<x>,<x>,... |
The compression ratio values. Each value is a factor of compression, thus 20 means 20 times compressed. The order is from left to right in descending order. A final lossless quality layer is signified by the value 1. The default is a single lossless quality layer. |
jp2:progression-order=<x> |
Choose from LRCP, RLCP, RPCL, PCRL or CPRL. |