mozilla/pdf.js · error · JpxError
No size marker found in JPX stream
Error message
No size marker found in JPX stream
What it means
Thrown by JpxImage.parseImageProperties() after scanning the entire stream byte-by-byte without finding the SIZ marker (0xFF51). The SIZ marker carries image/tile dimensions and component count; without it the image properties cannot be determined.
Source
Thrown at src/core/jpx.js:116
// Image and tile size (SIZ)
if (code === 0xff51) {
stream.skip(4);
const Xsiz = stream.getInt32() >>> 0; // Byte 4
const Ysiz = stream.getInt32() >>> 0; // Byte 8
const XOsiz = stream.getInt32() >>> 0; // Byte 12
const YOsiz = stream.getInt32() >>> 0; // Byte 16
stream.skip(16);
const Csiz = stream.getUint16(); // Byte 36
return {
width: Xsiz - XOsiz,
height: Ysiz - YOsiz,
// Results are always returned as `Uint8ClampedArray`s.
bitsPerComponent: 8,
componentsCount: Csiz,
};
}
}
throw new JpxError("No size marker found in JPX stream");
}
}
export { JpxError, JpxImage };
View on GitHub (pinned to 5903d58d58)
Solutions
- Verify the stream begins with a JP2 signature (\x00\x00\x00\x0cjP ) or a J2K codestream SOC (0xFF4F) followed by SIZ (0xFF51).
- Confirm /Filter is actually JPXDecode and that earlier filters (e.g. FlateDecode) were applied.
- Check the stream isn't truncated — ensure /Length matches available bytes.
- Catch JpxError and render a placeholder.
Defensive patterns
Strategy: validation
Validate before calling
// Confirm a JP2/J2K header and SIZ marker exist
function looksLikeJpx(data) {
const isJp2 = data.length >= 12 && data[0]===0 && data[1]===0 && data[2]===0 && data[3]===0x0c;
const isJ2k = data.length >= 2 && data[0] === 0xff && data[1] === 0x4f;
return isJp2 || isJ2k;
} Try / catch
try { const props = JpxImage.parseImageProperties(stream); }
catch (e) { if (e.name === 'JpxError' && /size marker/.test(e.message)) { /* not JPX */ } else throw e; } Prevention
- Verify the stream has a JP2/J2K signature before calling parseImageProperties.
- Ensure /Filter is JPXDecode and earlier filters were applied.
- Confirm the stream isn't truncated before the SIZ marker.
When it happens
Trigger: parseImageProperties reads bytes until newByte < 0 (end of stream) without code === 0xFF51. Means the data has no JPEG2000 SIZ segment — it's not JPEG2000, is truncated before SIZ, or is corrupt.
Common situations: A PDF image XObject with /Filter /JPXDecode whose stream isn't actually JP2/J2K (mislabeled), a truncated JPX stream, or random data routed to the JPX decoder. The SIZ marker is mandatory and near the start of every valid codestream.
Related errors
- ${errorMessages}
- JpegImage.parse - unknown marker: ${fileMarker.toString(16)}
- JpegImage.parse - no frame data found.
- Unknown error
- Invalid data format, must be a TypedArray.
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/ddb403e74771472e.
Report an issue: GitHub.