JP2 File Documentation


Summary

A JPEG 2000 Core Image File (.jp2) is a raster image compressed with wavelet maths instead of the block-based DCT that ordinary JPG uses. Standardised in 2000 as ISO/IEC 15444-1, it supports both lossless and lossy coding and its MIME type is image/jp2. Only Safari displays it in a browser, so the usual question is how to view one: open it in IrfanView, XnView or Photoshop, or convert it to JPG or PNG.

Technical details

FeatureValue
Full nameJPEG 2000 Core Image File (JP2)
File extension.jp2
MIME typeimage/jp2
Format typeWavelet-compressed raster image (lossy and lossless)
CompressionDiscrete wavelet transform (DWT); reversible 5/3 or irreversible 9/7 filter
DeveloperJoint Photographic Experts Group (ISO/IEC + ITU-T)
Introduced2000 (JPEG 2000 Part 1)
StandardISO/IEC 15444-1 (JPEG 2000 image coding system: core coding)
Open standardYes — the core coding system is royalty-free
Container / base formatBox structure derived from the ISO Base Media File Format family
Byte orderBig-endian
Bit depth1–38 bits per component, signed or unsigned
ColourGrayscale, sRGB, or an embedded ICC profile via the colr box
Alpha channelYes — declared in the Channel Definition (cdef) box
Magic number (hex)00 00 00 0C 6A 50 20 20 0D 0A 87 0A
Codestream markerStarts with SOC FF 4F, then SIZ FF 51
ProgressionBy resolution, quality layer, spatial position or component
Related extensions.j2k, .j2c, .jpx, .jpf, .jpc, .jpg, .tiff
Specificationiso.org/standard/78321.html
File signature (magic bytes)
00 00 00 0C 6A 50 20 20 0D 0A 87 0A

Offset 0, 12 bytes. This is the JP2 Signature box: a 4-byte length 00 00 00 0C (12), the box type 6A 50 20 20 which is ASCII jP  , then the fixed content 0D 0A 87 0A. The CR–LF and 0x87 bytes act as a transfer-damage check, the same idea as PNG’s signature. A bare JPEG 2000 codestream (.j2k/.j2c) has no box wrapper and instead begins with the SOC marker FF 4F followed by SIZ FF 51.

What is a JP2 file?

JP2 is the standard file format of JPEG 2000, an image coding system published in 2000 by the Joint Photographic Experts Group as ISO/IEC 15444-1. It is the same committee that produced ordinary JPEG a decade earlier, but the two formats share almost nothing internally. Classic JPEG cuts an image into 8×8 blocks and applies a discrete cosine transform (DCT) to each. JPEG 2000 instead applies a discrete wavelet transform (DWT) to whole tiles, which removes the blocky artefacts that DCT produces at high compression and, in one of its two modes, allows perfectly lossless coding.

A .jp2 is not a raw stream of compressed pixels. It is a small container of typed boxes that wraps the compressed codestream and describes how to interpret it: image size, bit depth, colour space and optional metadata such as georeferencing. The MIME type is image/jp2. Everything below is about how those boxes are laid out and how the wavelet codestream inside them is organised.

The box structure: signature, ftyp, jp2h and jp2c

A JP2 file is a flat sequence of boxes. Each box begins with an 8-byte header: a 32-bit big-endian length (LBox) covering the whole box including this header, then a 32-bit type (TBox) written as four ASCII characters. If LBox equals 1, a 64-bit extended length (XLBox) follows the type; if it equals 0, the box runs to the end of the file. That is the same length-prefixed, self-describing design used by MP4 and the wider ISO Base Media file family, so a reader can skip any box it does not recognise.

Signature box   'jP  '   12 bytes, fixed: 00 00 00 0C 6A 50 20 20 0D 0A 87 0A
File Type box   'ftyp'   brand 'jp2 ', minor version, compatibility list
JP2 Header box  'jp2h'   SUPERBOX, holds:
  ├─ 'ihdr'   image header: height, width, #components, bit depth
  ├─ 'bpcc'   bits per component (only if components differ)
  ├─ 'colr'   colour spec: enumerated (sRGB/greyscale) or embedded ICC
  ├─ 'pclr'   palette (optional)
  ├─ 'cmap'   component-to-palette mapping (optional)
  ├─ 'cdef'   channel definitions incl. alpha (optional)
  └─ 'res '   capture / display resolution (optional)
Codestream box  'jp2c'   the wavelet-compressed image data (see below)
XML / UUID      'xml ' / 'uuid'   optional metadata (XMP, GeoJP2 georeferencing)

The first four boxes are effectively mandatory. The signature box is the fixed 12-byte magic number. The File Type box (ftyp) names the brand the file claims: a conforming Part 1 file lists jp2 . The JP2 Header box (jp2h) is a superbox, meaning its payload is itself a run of boxes, and it carries no pixel data, only description. The actual coded image lives in the Contiguous Codestream box (jp2c).

The ihdr and colr boxes: dimensions, depth and colour

Inside jp2h, the Image Header box (ihdr) is a fixed 14-byte payload read in a strict order: a 32-bit HEIGHT, a 32-bit WIDTH, a 16-bit component count NC, an 8-bit BPC (bits per component minus one, with the top bit flagging signed samples), an 8-bit compression type C that is always 7 for JPEG 2000, and two flag bytes for unknown-colourspace and intellectual-property markers. Because BPC is a single field, all components share one bit depth unless a separate Bits Per Component box (bpcc) overrides it per channel. JPEG 2000 permits 1 to 38 bits per component, far beyond the 8 bits of baseline JPEG, which is why the format suits medical and satellite imagery.

The Colour Specification box (colr) says how to turn component values into colour. Its METH field selects either an enumerated colour space (a code such as 16 for sRGB or 17 for greyscale) or a restricted ICC profile embedded directly in the box. When an image carries transparency, the Channel Definition box (cdef) maps each component to a role: colour, opacity (alpha), or premultiplied opacity. So a JP2 knows a channel is alpha only because cdef declares it, not by position.

The wavelet codestream: SIZ, COD and marker segments

The bytes inside jp2c are a self-contained JPEG 2000 codestream, the same thing you would find standing alone in a .j2k file. It is a sequence of markers, each a two-byte code in the range FF 30FF FF; markers that carry parameters are followed by a length and a marker segment. The stream opens with SOC (Start of Codestream, FF 4F) and ends with EOC (FF D9).

FF 4F              SOC   start of codestream
FF 51 .. SIZ       image and tile sizes, component count, bit depth
FF 52 .. COD       coding style: #decomposition levels, code-block size,
                   wavelet filter (5/3 reversible or 9/7 irreversible),
                   progression order, number of quality layers
FF 5C .. QCD       quantisation: step sizes per subband
FF 90 .. SOT       start of a tile-part (repeats per tile)
FF 93              SOD   start of data — packets follow
FF D9              EOC   end of codestream

The SIZ segment (FF 51) is the codestream’s own header. It records the reference grid size, the tile size, the image offset, and per component the bit depth and the horizontal and vertical sub-sampling. The COD segment (FF 52) sets the coding style: how many DWT decomposition levels are applied, the code-block dimensions, which wavelet filter is used (the reversible 5/3 integer filter for lossless work, the irreversible 9/7 float filter for maximum lossy quality), the progression order, and the number of quality layers. QCD (FF 5C) then gives the quantisation step size for each wavelet subband.

Tiles, resolution levels and packets

The DWT is what makes JPEG 2000’s headline features possible, and it works through a small hierarchy. First, the image can be divided into rectangular tiles that are coded independently, so a decoder can render one region of a huge picture without touching the rest. Within a tile, each wavelet decomposition level produces a lower-resolution version of the image plus detail subbands, so the same codestream holds the picture at many resolutions at once: a decoder wanting a thumbnail reads only the coarsest level and stops.

Each subband is split into code-blocks, and each code-block is entropy-coded bit-plane by bit-plane with the EBCOT arithmetic coder (Embedded Block Coding with Optimised Truncation). The coded bits are then assembled into packets, and the order in which packets appear is the progression order set in COD. The five orders (abbreviated by their axes, for example LRCP for layer-resolution-component-position) let the same bytes be delivered quality-first, resolution-first or position-first. Truncating the codestream early simply drops the least important packets, which is how one JP2 can serve both a low-bandwidth preview and a full-quality master from the same file.

Reversible and irreversible modes

JPEG 2000 has two distinct compression paths chosen in the COD and QCD segments. The reversible path uses the integer 5/3 wavelet with no quantisation loss, so decoding reproduces the original samples exactly: true lossless. The irreversible path uses the floating-point 9/7 wavelet with quantisation, trading exactness for smaller files, and it degrades gracefully rather than blocking. A single archival workflow often keeps a lossless 5/3 master and derives 9/7 access copies from it. This is a real advantage over baseline JPG, which is lossy only, and it is why the Library of Congress and national archives store scanned masters as lossless JP2 rather than JPEG.

JP2 versus the raw codestream, JPX and JPF

The extension you see tells you which wrapper is present, not which compression. A .jp2 is the Part 1 box container described here. A .j2k or .j2c is the bare codestream with no boxes: identical wavelet data, starting straight at the SOC marker, with no ihdr or colr to describe colour, so a viewer must guess or be told. A .jpx or .jpf is JPEG 2000 Part 2 (ISO/IEC 15444-2), an extended container that adds richer colour spaces, multiple compositing layers and animation on top of the same box model. Reading the four-character box types is the reliable way to tell them apart, since all of them can hold the same underlying codestream.

Why you rarely see JP2 on the web

The compression is strong, so the format’s obscurity is not technical. The blocker is decoder support. As of 2026 only Apple Safari renders .jp2 natively; Chrome, Firefox and Edge do not, so a JP2 embedded in a normal web page simply fails to display. Wavelet decoding is also heavier on the CPU than DCT, and early adoption was slowed by patent uncertainty around some optional coding tools. The result is that JP2 lives where its strengths pay off and browser support does not matter: digital preservation, medical imaging (often alongside DICOM), satellite and geospatial tiles with embedded GeoJP2 georeferencing, and Digital Cinema packages. For everyday sharing, converting to JPG or PNG is the practical move.

Frequently asked questions

Why does a JP2 start with a 12-byte signature box rather than a short magic number?

Because the signature is itself a valid box. The first four bytes are its length (12), the next four are its type (jP  ), and the final four (0D 0A 87 0A) are its content. Building the magic number as a real box keeps the whole file a uniform stream of length-prefixed boxes, and the CR–LF and high-bit bytes double as a check that a text-mode transfer has not corrupted the file.

How can a viewer show one small area of a gigapixel JP2 without reading it all?

Through tiling and packet structure. The image is coded as independent tiles at several resolution levels, and the codestream records where each tile-part and packet begins. A reader consults that structure, seeks to just the packets covering the wanted region and resolution, and decodes only those. Nothing forces it to load the whole codestream, which is why JPEG 2000 suits maps and archival scans that are far too large to hold in memory.

References