{"record":{"id":"ddb403e74771472e","repo":"mozilla/pdf.js","slug":"no-size-marker-found-in-jpx-stream","errorCode":null,"errorMessage":"No size marker found in JPX stream","messagePattern":"No size marker found in JPX stream","errorType":"exception","errorClass":"JpxError","httpStatus":null,"severity":"error","filePath":"src/core/jpx.js","lineNumber":116,"sourceCode":"      // Image and tile size (SIZ)\n      if (code === 0xff51) {\n        stream.skip(4);\n        const Xsiz = stream.getInt32() >>> 0; // Byte 4\n        const Ysiz = stream.getInt32() >>> 0; // Byte 8\n        const XOsiz = stream.getInt32() >>> 0; // Byte 12\n        const YOsiz = stream.getInt32() >>> 0; // Byte 16\n        stream.skip(16);\n        const Csiz = stream.getUint16(); // Byte 36\n        return {\n          width: Xsiz - XOsiz,\n          height: Ysiz - YOsiz,\n          // Results are always returned as `Uint8ClampedArray`s.\n          bitsPerComponent: 8,\n          componentsCount: Csiz,\n        };\n      }\n    }\n    throw new JpxError(\"No size marker found in JPX stream\");\n  }\n}\n\nexport { JpxError, JpxImage };\n","sourceCodeStart":98,"sourceCodeEnd":121,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/jpx.js#L98-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm a JP2/J2K header and SIZ marker exist\nfunction looksLikeJpx(data) {\n  const isJp2 = data.length >= 12 && data[0]===0 && data[1]===0 && data[2]===0 && data[3]===0x0c;\n  const isJ2k = data.length >= 2 && data[0] === 0xff && data[1] === 0x4f;\n  return isJp2 || isJ2k;\n}","typeGuard":null,"tryCatchPattern":"try { const props = JpxImage.parseImageProperties(stream); }\ncatch (e) { if (e.name === 'JpxError' && /size marker/.test(e.message)) { /* not JPX */ } else throw e; }","preventionTips":["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."],"tags":["jpeg2000","format-validation","image-decoding","corrupt-data","jpx"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}