Unix
Mac OS X
iOS
Windows
Processing
Options
Usage
MagickWand
MagickCore
PerlMagick
Magick++
Unix
Windows
Links

# ImageMagick JPEG-2000 Image Format

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:

$ convert wizard.png -define jp2:cblkwidth=64 -define jp2:cblkheight=32 \
-define jp2:nomct -define jp2:numrlvls=4 -define jp2:rate=0.015625 wizard.jpc

Here we convert a giga-byte TIFF image to JPEG-2000 with a reduced memory footprint:

$ convert frame-00038.tif -define jp2:tilewidth=256 -define jp2:tileheight=256 frame-00038.jp2

Here is a lossy example using the full gamut of JP2 options:

$ convert input.tif -define numrlvls=7 -define jp2:tilewidth=1024 -define jp2:tileheight=1024 \
-define jp2:rate=0.02348 -define jp2:prg=rpcl -define jp2:mode=int -define jp2:prcwidth=16383 \
-define jp2:prcheight=16383 -define jp2:cblkwidth=64 -define jp2:cblkheight=64 -define jp2:sop output.jp2

Here is the same example with lossless encoding:

$ convert input.tif -define jp2:numrlvls=6 -define jp2:tilewidth=1024 -define jp2:tileheight=1024 \
-define jp2:rate=1.0 -define jp2:lazy -define jp2:prg=rlcp -define jp2:ilyrrates=\
'0.015625,0.01858,0.0221,0.025,0.03125,0.03716,0.04419,0.05,0.0625, 0.075,0.088,0.1,0.125,0.15,0.18,0.21,0.25,0.3,0.35,0.4,0.5,0.6,0.7,0.84' \
-define jp2:mode=int output.jp2

Here is a complete list of JPEG-2000 encoding options:

imgareatlx=x
  Set the x-coordinate of the top-left corner of the image area to x.
imgareatly=y
  Set the y-coordinate of the top-left corner of the image area to y.
tilegrdtlx=x
  Set the x-coordinate of the top-left corner of the tiling grid to x.
tilegrdtly=y
  Set the y-coordinate of the top-left corner of the tiling grid to y.
tilewidth=w
  Set the nominal tile width to w.
tileheight=h
  Set the nominal tile height to h.
prcwidth=w
  Set the precinct width to w. The argument w must be an integer power of two. The default value is 32768.
prcheight=h
  Set the precinct height to h. The argument h must be an integer power of two. The default value is 32768.
cblkwidth=w
  Set the nominal code block width to w. The argument w must be an integer power of two. The default value is 64.
cblkheight=h
  Set the nominal code block height to h. The argument h must be an integer power of two. The default value is 64.
mode=m
  Set the coding mode to m. The argument m must have one of the following values:

  Value | Description
  --- | ---
  int | integer mode
  real | real mode

  If lossless coding is desired, the integer mode must be used. By default, the integer mode is employed. The choice of mode also determines which multicomponent and wavelet transforms (if any) are employed.
rate=r
  Specify the target rate. The argument r is a positive real number. Since a rate of one corresponds to no compression, one should never need to explicitly specify a rate greater than one. By default, the target rate is considered to be infinite.
ilyrrates=r0[,r1,. . . ,rN]
  Specify the rates for any intermediate layers. The argument to this option is a comma separated list of N rates. Each rate is a positive real number. The rates must increase monotonically. The last rate in the list should be less than or equal to the overall rate (as specified with the rate option).
prg=p
  Set the progression order to p. The argument p must have one of the following values:

  Value | Description
  --- | ---
  lrcp | layer-resolution-component-position (LRCP) progressive (i.e., rate scalable)
  rlcp | resolution-layer-component-position (RLCP) progressive (i.e., resolution scalable)
  rpcl | resolution-position-component-layer (RPCL) progressive
  pcrl | position-component-resolution-layer (PCRL) progressive
  cprl | component-position-resolution-layer (CPRL) progressive

  By default, LRCP progressive ordering is employed. Note that the RPCL and PCRL progressions are not valid for all possible image geometries.
nomct
  Disallow the use of any multicomponent transform.
numrlvls=n
  Set the number of resolution levels to n. The argument n must be an integer that is greater than or equal to one. The default value is 6.
sop
  Generate SOP marker segments.
eph
  Generate EPH marker segments.
lazy
  Enable lazy coding mode (a.k.a. arithmetic coding bypass).
termall
  Terminate all coding passes.
segsym
  Use segmentation symbols.
vcausal
  Use vertically stripe causal contexts.
pterm
  Use predictable termination.
resetprob
  Reset the probability models after each coding pass.
numgbits=n
  Set the number of guard bits to n.

Discourse Server • Public Key • Studio • JqMagick