Skip to content

fix(raster): JPEG refusals name their values, orientation calls documented, guards pinned - #681

Merged
github-actions[bot] merged 1 commit into
devfrom
lead/image-codecs-r3-jpeg-b1
Oct 19, 2026
Merged

github-actions[bot] merged 1 commit into
devfrom
lead/image-codecs-r3-jpeg-b1

Conversation

@prakashUXtech

@prakashUXtech prakashUXtech commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Anatomy round 3, IC-jpeg, batch b1. This PR fixes the eight findings from the JPEG review. It is part of #562.

What and why

  1. Orientation calls documented. The doc on JPEGInfo.orientation now lists the PixelBuffer calls for each EXIF value 1...8: flipped(.horizontal), rotated(.degrees180), flipped(.vertical), transpose = rotated(.degrees90) then flipped(.horizontal), rotated(.degrees90), transverse = rotated(.degrees270) then flipped(.horizontal), and rotated(.degrees270). Proved by JPEGReadTests.orientationCallsTurnUpright: it applies each documented call to a 2x3 frame and compares the result with the EXIF definition.
  2. What CodecError.unsupported covers. Its doc now says it covers both a file feature the codec does not read or write and an encoder option the caller asked for. JPEG.write says that a quality outside 1...100 is a caller argument. This change is docs only.
  3. Refusals print the values they read. The SOF component refusal prints H, V and Tq. The n-component refusal names the count, and says CMYK/YCCK when it is 4. The missing-DQT refusals print the component id and the table. The block-bound refusal prints how many bytes come after the scan header. pixels() now splits "no SOF" from the sRGB transfer failure. Proved by JPEGReadGuardTests.sofRefusalsPrintValues, blockBoundNamed and JPEGReadTests.damagedThrows.
  4. Width 0. Proved by JPEGReadGuardTests.widthZero: both info and read throw damaged containing "width 0". Mutation entry: CoreRaster.JPEG "SOF width 0".
  5. SOS missing-DQT refusal is observable. It now reads "scan component 2 uses DQT 1, not defined before its scan". Exact text is asserted in JPEGReadTests.damagedThrows. Mutation entry: "SOS no longer refuses a component without its DQT".
  6. EXIF wrong type. Proved by JPEGReadGuardTests.exifOrientationWrongType: an Orientation entry typed ASCII or LONG reads as 1, and a SHORT control reads as 6. The fixture exif gains a type: argument. Mutation entry: "EXIF Orientation type check is dropped".
  7. DHT with more than 256 values. This case now has its own guard and message, "DHT 0x00 has 300 values (256 at most)". Proved by a new case in JPEGReadGuardTests.badTableNamesItInHex. Mutation entry: "DHT of over 256 values".
  8. Remaining guards pinned. New mutation entries cover the maxSide limit, segment length under 2 (segmentLengthUnderTwo), SOF Tq over 3, 4-component SOF, progressive AC-before-DC, and a progressive band past 63. The band case also gets a message assertion in JPEGReadTests.progressiveScanChecks. seededSOFFieldsThrow randomises SOF fields with seeded SplitMix64 and checks that every read throws a CodecError or decodes.

New byte fixtures are built as lists of parts, as in #665, so the macOS type checker can handle them.

No platform or library API is new here: only Swift stdlib basics already used in these files. The docs MCP tools were not needed for that.

Gate

scripts/ci printed CI: PASS on the head below, after rebasing on dev. scripts/mutate --run --changed-since origin/dev caught 33/33.

Belt-Lead: act-1a15227fc25-tkce
Feature: image-codecs
Slice: IC-jpeg
Mutate: 33/33 CoreRaster.JPEG, CoreRaster.JPEGDecode, CoreRaster.JPEGProgressive, CoreRaster.JPEGWrite, CoreRaster.StackXML
Fast-Check: pass
Head: 468358b

@prakashUXtech prakashUXtech added the fast-lane Small green PR, auto-merge when eligible label Oct 19, 2026 — with Claude
@github-actions
github-actions Bot merged commit 3d9c151 into dev Oct 19, 2026
1 check passed
@github-actions github-actions Bot added the fast-lane-merged Merged by the fast lane; review after the fact label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Fast lane: merged into dev (181 lines, 9 files, Fast-Check marker).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-lane Small green PR, auto-merge when eligible fast-lane-merged Merged by the fast lane; review after the fact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant