Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6c78b2f
fix(images): mask a PNG colour key to the bit depth before writing it
Tim81 Nov 29, 2026
910887e
fix(images): write a black Matte for an associated-alpha TIFF
Tim81 Nov 29, 2026
358c85b
fix(images): refuse a JPEG 2000 codestream that sets the Part 2 Rsiz bit
Tim81 Nov 29, 2026
5df8405
fix(images): refuse JPEG and JPEG 2000 frames the filters cannot carry
Tim81 Nov 29, 2026
b44c155
Merge origin/main into fix/image-audit-gaps
Tim81 Nov 29, 2026
2e52616
feat(layout): report JP2 images that PDF/A-2 6.2.8.3 does not allow
Tim81 Nov 29, 2026
5877cd8
docs(layout): name the JP2 PDF/A diagnostic in the diagnostics list
Tim81 Nov 29, 2026
36f4ab4
fix(images): write a JP2 device name only for a channel count it fits
Tim81 Nov 30, 2026
4601eef
docs(conformance): mark the image gaps #763, #764, #768 and #770 fixed
Tim81 Nov 30, 2026
1eac2c5
test(images): give the greyscale colr test a channel count the loader…
Tim81 Nov 30, 2026
b1a9d57
fix(images): count JP2 colour channels as the standards do, report th…
Tim81 Nov 30, 2026
c7653ce
docs(conformance): state the JP2 colour-channel rule and the 6.2.8.3 …
Tim81 Nov 30, 2026
d21cd90
docs(images): say what the NEN reading of 6.2.8.3 and Rsiz settles
Tim81 Nov 30, 2026
9583ec6
fix(images): refuse only the Part 2 capabilities the JPX baseline exc…
Tim81 Nov 30, 2026
8e5e4b1
fix(images): check a lone colr box against the colour channels, count…
Tim81 Dec 1, 2026
3098e4e
docs(conformance): state the lone-colr channel check, the JPX cmap ru…
Tim81 Dec 1, 2026
64c49be
docs(images): say why the sRGB and greyscale counts are not cited to …
Tim81 Dec 1, 2026
034be90
Merge origin/main into fix/image-audit-gaps
Tim81 Dec 1, 2026
7e6f6c7
fix(images): keep main's name where it fits a lone colr box, refuse n…
Tim81 Dec 1, 2026
9d2c194
Merge remote-tracking branch 'origin/main' into fix/image-audit-gaps
Tim81 Dec 1, 2026
4144bd2
fix(images): one colour-channel reading, refuse JP2 files PDF cannot …
Tim81 Dec 1, 2026
b606e47
fix(images): an incomplete cdef box keeps a name that fits either col…
Tim81 Dec 1, 2026
6b76247
fix(images): judge each cdef reading on name and depth together
Tim81 Dec 1, 2026
4e18f54
docs(images): say which depths the LayoutImage refusal covers
Tim81 Dec 1, 2026
8783099
test(images): pin the depth check of a cdef box that describes every …
Tim81 Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,115 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Fixed

- **JPEG and JPEG 2000 data that DCTDecode and JPXDecode cannot carry is refused, and a JP2 colour
specification is no longer overridden by a device name (#763).** `JpegImageLoader` chose
`/DeviceRGB` for every component count other than 1 and 4 and accepted every frame type and
precision, and `JpxImageLoader` wrote a device name from the channel count whatever the `colr`
box or the count said. ISO 32000-2, 7.4.8, gives DCTDecode data one, three or four components of
a byte each, and 7.4.9 says a `ColorSpace` that is present replaces the colour specification in
the JPEG 2000 data and that the ordinary colour channels shall match its components. `Load` now
throws `InvalidDataException` for a JPEG frame with a component count other than 1, 3 or 4, a
precision other than 8, or a frame type other than SOF0, SOF1 and SOF2, which also covers a
JPEG strip of a TIFF. It throws for a bare JPEG 2000 codestream, or a JP2 file with no `jp2h`
box, of a channel count other than 1, 3 or 4. For a JP2 file with a `jp2h` box it counts the
colour channels as the `JpxImageLoader` documentation defines them (ISO/IEC 15444-1, I.5.3.6),
and throws unless the device name it would write has exactly that many components. So two
channels or three beside greyscale, one beside sRGB, and two or five with no `colr` box and no
`cdef` box are refused, while a greyscale file whose `cdef` box marks one colour and one opacity
channel is written as `/DeviceGray`, and so is an RGB file of five channels whose `cdef` box marks
three colour channels. Where a `colr` box names CMYK and four colour channels fit no other name,
the file is written as `/DeviceCMYK`. A file with a `pclr` box is not checked against
its channel count, because a palette changes what the channels are, and neither is a JPX file
(brand `jpx ` or `jpxb`) with a `cmap` box and no `pclr` box; in a JP2 file such a `cmap` box is
not allowed and the file is judged by its channel count. A JP2
file with exactly one `colr` box that holds an ICC profile or names an enumerated space other
than sRGB, greyscale and CMYK (sYCC, say) is written with no `ColorSpace` when the colour
channels have as many components as that space (an enumerated space by the colour model it names,
an ICC profile by the colour space in its header), so the file's own specification decides. When
they do not, 7.4.9 still allows a `ColorSpace` with as many components as the colour channels, so
the file keeps the name the channel count chooses where that name fits, as before, and is
refused where it does not, such as an sYCC box beside two or five channels; ISO/IEC 15444-1:2024,
Annex I, ties the channel count to the colours of the colour space only inside the `cdef` box.
A JP2 file none of whose readable `colr` boxes is an allowed colour specification is refused,
whatever its channels and `ColorSpace` are, with the boxes named in the message: 7.4.9 limits
the data to the JPX baseline set of features other than enumerated colour space 19 (CIEJab) and
ISO/IEC 15444-2:2004, M.9.2.4, asks of that set a colour specification from its list, so no
`ColorSpace` makes such a file valid. A colour specification is allowed when it is an ICC profile
(method 2 or 3), CMYK (12), or an enumerated space of that list other than CIEJab: sRGB (16),
greyscale (17), CIELab (14), sYCC (18), e-sRGB (20), ROMM-RGB (21) and e-sYCC (24). The refused
enumerated values are 0 to 11, 13, 15, 19, 22, 23 and every value above 24, reserved ones
included, and the refused methods are any other than 1, 2 and 3, so a lone vendor box, two
reserved values, and a vendor box beside CIEJab are refused. One allowed box is enough: a file
with a vendor box beside an ICC profile, or two or more `colr` boxes of which one is allowed and
none a device space, keeps the device name it had, because veraPDF 1.30.4 fails such a file of one
or three channels under PDF/A-2b without it. A box too short to read (under 3 bytes, or method 1
under 7) is a colour specification of neither kind, so a file with only such boxes is not
refused for them. A JP2 file with no `colr` box is not refused for the absence. A Layout
save under a PDF/A-2 claim reports as the new `LayoutDiagnosticCode.JpxImageNotAllowedByPdfA`
(501), an error that `StrictDiagnostics` refuses, a JP2 file that ISO 19005-2, 6.2.8.3, does not
allow: more than one colour specification and not exactly one with an APPROX of 1, a colour
specification whose METH is not 1, 2 or 3, colour channels of different bit depth, or a number of
colour channels other than 1, 3 or 4 for a file written with no `ColorSpace`. 7.4.9 requires none
of those four. It does limit bits per sample to 1 through 38, so a JP2 file (or a bare
codestream) is refused in every document when every reading of its channels that the name fits has
a colour channel deeper than that (the `JpxImageLoader` documentation states the readings); a file with a palette is not read for it. A `bpcc` box with more entries than the
image has channels is not a conforming JP2 file (ISO/IEC 15444-1, I.5.3.2), its extra entries
are no channels, and the file is refused, with that said, when one of them is deeper than 38
bits. The depths are read from the `bpcc` box, else from the codestream
where the loader takes the dimensions from it, else from the `ihdr` box, which gives none when
its BPC is 255 and the file has no `bpcc` box. The report follows the clause, not veraPDF, which
checks APPROX and METH only without a `ColorSpace` and also fails a sign-only difference and an
opacity channel of another depth. It names the image by its size and the clause and quotes no
alternative text; without a claim nothing changes.
**Deliberate output changes and new refusals:** those inputs, and the new diagnostic under a
PDF/A-2 claim; every other JPEG (SOF0 to SOF2, 8-bit, 1, 3 or 4 components) and every JP2 file
whose name has as many components as it has colour channels, or that has a palette, writes the
same bytes as before, and so does a JP2 file with one `colr` box that is not a device space where
the name the channel count chooses has as many components as the colour channels. A `cdef` box
that leaves a channel undescribed has two readings of its colour channels, and the file keeps
main's bytes only under a reading whose colour-channel count the name has and whose colour
channels are all 1 to 38 bits deep (as the `JpxImageLoader` documentation states); it is refused
when no reading passes both checks, with a message that names the failed check of each.

- **A JPEG 2000 codestream whose Rsiz requires a capability outside the JPX baseline is refused
(#770).** ISO 32000-2, 7.4.9, limits the data of an image XObject to the JPX baseline set of
features, and `JpxImageLoader` never read the `Rsiz` field of the SIZ marker, so such a codestream
was wrapped and written. ISO/IEC 15444-2:2004, M.9.2.3, defines that set as Part 1 plus only the
irreversible decorrelation and non-linearity extensions. `Load` now throws `InvalidDataException`
naming `Rsiz`, when bit 15 (Part 2 capabilities) is set together with any of bits 0, 1, 4, 5, 6,
7, 10 or 11, the capabilities that Table A.2 of that part says are required to decode, and when
bit 14 is set (extended capabilities through a CAP marker; ISO/IEC 15444-1, Table A.10). Bit 15
alone, the "useful" bits 2, 3 and 9, and bit 8 (multiple component transformation) pass: the
baseline allows the irreversible decorrelation, and its limits on the MCC and MCO marker segments
are not checked. The field is read in three cases: a bare codestream, the `jp2c` box of a JP2
file whose codestream starts with SOC and SIZ, and a JP2 file whose dimensions the loader takes
from the codestream because it has no `jp2h` box or no usable `ihdr` box (absent, or with a height
or width of 0). A JP2 file with a usable `ihdr` box and a codestream that does not start with SOC
and SIZ is not examined.
**Deliberate new refusal:** a codestream whose `Rsiz` has bit 14 set, or bit 15 together with one
of the listed required bits; every other codestream writes the same bytes as before.

- **A TIFF with associated alpha is written with a black Matte on its soft mask (#764).** TIFF
6.0 says `ExtraSamples` 1 holds colour samples already multiplied by alpha, which is the
pre-blending of ISO 32000-2, 11.6.5.2, with a black matte, and a soft-mask image with no
`Matte` says its image data are not pre-blended. `TiffImageLoader` read the tag and dropped it,
so a reader composited the multiplied samples a second time and the image came out darker than
the source. The soft mask now carries `/Matte [0 0 0]` and the samples are written as they were.
**Deliberate output change:** the soft-mask dictionary of an RGBA TIFF whose `ExtraSamples` is 1
and whose alpha is not 255 everywhere (8-bit, and 16-bit under either `ImageBitDepth`); a TIFF
with `ExtraSamples` 2 or none, and one whose alpha is opaque throughout, write the same bytes as
before.

- **A PNG colour key is masked to the bit depth before it is written (#768).** The PNG
specification stores a grey or RGB `tRNS` key as 16-bit words whatever the depth and has a
decoder mask the bits above the depth to 0. `PngImageLoader` rescaled the raw word, so a valid
PNG whose key held stray high bits was written with a `Mask` entry above
2^BitsPerComponent - 1, which ISO 32000-2, 8.9.6.4, forbids, and a reader then painted the pixel
the PNG marks transparent. The word is now masked to the depth first. **Deliberate output
change:** the `Mask` array of a PNG whose `tRNS` word has bits above the depth (for example grey
8-bit with `01 10`, now `[16 16]`); a PNG whose key bits above the depth are zero, a 16-bit PNG
and a PNG with no key write the same bytes as before.

- **A nested unordered list marker is no longer drawn as `?` in a Standard 14 font (#545).** The
white bullet, U+25E6, is not in WinAnsiEncoding, so a Standard 14 font wrote it as `?` and
recorded one `TextEncodingWarning` per marker. A marker is now the first of its level's
Expand Down
Loading
Loading