Images — JPEG, PNG and JPEG 2000, since 1.9.0 for JPEG 2000
An image block embeds the file's own bytes: a JPEG as /DCTDecode, a PNG as /FlateDecode with its alpha channel split into a soft mask, and since 1.9.0 a JPEG 2000 file as /JPXDecode — colour space and bit depth left to the codestream when its header declares them, an opacity channel as /SMaskInData 1, the header raised to PDF 1.5. Nothing is decoded or recompressed. The fixtures are tiny images inlined in this page; pick a file of your own for the last preset.
View underlying code
Diagnostics (layout.onDiagnostic)
Generate a PDF to see the diagnostics its build raised. Every preset wires layout.onDiagnostic; a plain document raises none, and PDF/A-2b with the embedded font raises none either — the JPEG 2000 fixture has three colour channels and an opacity channel, which ISO 19005-2 §6.2.8.3 does not allow, so the PDF/A-2b preset raises PDFA_JPX_IMAGE and still writes the file.
Worth knowing:
- What is read: the JPEG SOF marker (dimensions, components), the PNG IHDR and IDAT chunks (8-bit, non-interlaced), the JP2
ihdr/colr/cdefboxes or the codestream's SIZ marker.parseImage(),parseJPX()anddetectImageFormat()expose the same readers. - JPEG 2000 is not decoded. pdfnative has no wavelet decoder; the viewer draws the codestream (Acrobat, Chrome's PDFium and Firefox's pdf.js do). The header becomes
%PDF-1.5, the version that introduced/JPXDecode. - PDF/A-1 (PDF 1.4) has no JPXDecode:
tagged: 'pdfa1b'with a JPEG 2000 image raisesPDFA1_JPX_IMAGE— a warning by default, a thrown error understrict. PDF/A-2 and 3 accept one, three or four colour channels and no opacity channel; anything else raisesPDFA_JPX_IMAGE(a warning, an error understrict). - Alpha: a PNG's alpha channel becomes a separate
/SMaskimage; a JPEG 2000 opacity channel stays in the codestream and the XObject says/SMaskInData 1. - Sizing:
widthandheightare points; give one and the aspect ratio supplies the other.altbecomes the/Figure's/Altin tagged mode.
See the Images guide for the full rules.