Commit Graph
158 Commits
Author SHA1 Message Date
aiongg 1e446ebe05 Merge pull request #2092 from aiongg/ci-speed-a
ci: faster Workspace gate: nextest everywhere, one test feature set, fuzz caps with a nightly full run, per-crate workflows without duplicates
2026-11-17 16:28:16 -05:00
Martin BallandClaude Sonnet 5.5 93dac78c93 craft-image-codecs: wrap a clipboard DIB as a BMP (dib_to_bmp, dib_layout) (#2062)
* image-codecs: wrap a clipboard DIB as a BMP (#778)

Add bmp_probe::dib_to_bmp (prepend the 14-byte file header, pixel offset
from the header with saturating arithmetic, try_reserve for the output)
and bmp_probe::dib_layout (V4/V5 alpha-mask BI_RGB becomes BI_BITFIELDS,
mask copy after the header). Both are ported from WordCraft's
crates/geom/src/picture.rs so it can drop its local copies. Tests compare
byte-for-byte with the originals over crafted DIBs and every prefix, and
decode wrapped results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* image-codecs: fix DIB offsets for V2/V3 bitfields and ambiguous mask copies (#778)

- dib_to_bmp no longer adds 12 appended-mask bytes to the pixel offset for 52- and
  56-byte BI_BITFIELDS headers, which carry their masks inside the header; the
  decoder reads the pixels at bfOffBits, so the offset was 12 bytes too far.
- dib_layout treats 12 bytes after the header that equal the masks as an existing
  copy only when more bytes follow than the pixels need, so an exact-length DIB
  whose pixels equal the masks gets its copy inserted.
- dib_layout reserves the 12 bytes before changing compression or masks, so a
  failed reservation returns the DIB unchanged; the mask bytes are a [u8; 12]
  array, not a heap copy.

The differential tests against the WordCraft originals now exclude exactly the
52/56-byte bitfields offset and the exact-length payload cases, and assert the new
behaviour for them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:45:56 -05:00
Martin BallandClaude Opus 5.5 1928693fbb image-codecs: header-only PNG pixel model and WebP alpha probes (#778) (#2064)
png_probe::pixel_model reads width, height, bit depth, colour type and tRNS
presence from IHDR and the chunk headers before IDAT without inflating iCCP;
PixelModel::bytes_per_pixel and has_alpha give a caller's pixel size and alpha.
webp_probe::has_alpha reads the VP8X alpha flag, the VP8L alpha_is_used bit,
and treats plain VP8 as opaque. Differential tests compare against WordCraft's
png_chunks as an oracle.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:27:53 -05:00
Martin BallandClaude Opus 5.5 ea02182945 image-codecs: add jpeg_worst_case_coefficients (#778) (#2063)
A conservative pre-decode coefficient budget for hostile JPEG headers: the
larger of JpegInfo::held_coefficients and a whole-picture estimate over every
progressive frame header (SOF2/6/10/14, any precision, sampling clamped to
1..=4), with the costliest frame charged at the first frame's size when the
header can't be followed. held_coefficients is unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:27:49 -05:00
aiongg ff502fb75f ci: run a fraction of the fuzz-style tests on pull requests, all of them nightly
craft-testkit's hostile hammer reads CRAFT_HOSTILE_DIVISOR=N: the unmodified
seed, every N-th truncation and 1/N of the rounds. hostile::divisor() gives the
same value to sweeps written without the hammer; craft-image-codecs' TIFF zoo
and malformed-header sweeps use it, with a different offset per input so the
inputs together still reach every position. Proptests without their own case
count read proptest's PROPTEST_CASES.

The Workspace gate and the media, audio, video and PDF workflows set
CRAFT_HOSTILE_DIVISOR=8 and PROPTEST_CASES=64. The longest of these tests
(craft-media's MXF hostile input, 1,310 s on Windows; craft-pdf's crypt
proptests, up to 257 s; the image-codecs sweeps, 140-162 s) drop to about an
eighth or a quarter. nightly.yml runs the whole workspace on Linux without
either variable, so every case still runs once a day.

The gate's test-input setup moves to scripts/ci-test-inputs.sh, shared by both
workflows; it uses a corpus that is already present.
2026-11-17 19:09:17 +00:00
.CooCoo 2b47d508da craft-image-codecs: test PngSuite against one pinned SHA-256 list (#1382) 2026-11-16 21:35:52 -05:00
Dylan M. TaylorandBrandon Thomas a9efd722b4 Expose bounded BMP header recognition for consumer cutovers (#1929)
* Expose supported BMP header recognition

Port the BMP routing check from LightCraft commit 304180a500d1b3f87c8c841f269d305161d6c8b9, preserving minimum length and DIB allowlist.

* Test BMP routing boundaries and unsupported DIB sizes

---------

Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-11-16 17:56:38 -05:00
Dylan M. Taylor 5ef5134ccc image-codecs: keep stored WebP dimensions independent of EXIF compatibility (#1921) 2026-11-16 15:55:15 -05:00
FredApps 28e1b05e3c Merge pull request #1774 from vangel76/perf/dds-bc45-1766
DDS textures: normal maps and grayscale maps save compressed (BC5/BC4), and DDS saves and opens faster
2026-11-16 19:55:31 +01:00
FredApps 808df4f186 dds: validate public boundaries and bound fallible decoding 2026-11-16 18:01:22 +01:00
FredApps a58989cae9 image-codecs: skip a SubIFDs array whose offset is cut off (#1889)
camera_raw_mode read a missing SubIFDs offset as 0, so it walked the TIFF
header as the pointer array and could classify a malformed TIFF as RAW.
Skip the entry instead, matching LightCraft's classifier.
2026-11-16 10:26:36 -05:00
FredApps dd345db898 image-codecs: read a raster's resolution from its headers (resolution_probe) (#1838)
* image-codecs: read a raster's resolution from its headers (resolution_probe)

file_resolution(bytes) gives the pixels per inch a JPEG, PNG, WebP, BMP or
classic TIFF records without decoding pixels. JPEG uses the decoder's marker
scan (Photoshop, XMP, EXIF, then JFIF), PNG reads pHYs as the decoder does and
falls back to eXIf, WebP its EXIF chunk, TIFF its IFD0 tags; BMP reads the
info header's pixels per metre. Values outside 1-100000 ppi count as none.

DesignCraft (crates/images/src/resolution.rs) and FigCraft
(crates/format/src/density.rs) each carry their own marker and chunk walkers
for this; they can switch to the shared probe.

Part of #778 and #785.

* image-codecs: resolution_probe reads only a whole nine-byte pHYs, and a zero one leaves eXIf

A pHYs chunk that declares any other length, or is cut off before its
CRC, records nothing, and its data is no longer read from the bytes
after it. A zero pixels-per-metre count records nothing either, as in the
decoder, so the eXIf resolution still answers.
2026-11-16 08:14:38 -05:00
Dylan M. Taylor 731c4f262a Merge pull request #1758 from dotCooCoo/fix/exr-deep-part-tables-end
craft-exr: deep chunk offsets start after every part's offset table
2026-11-16 05:46:49 -05:00
Dylan M. Taylor 8a83e9178d Merge pull request #1837 from ljkx/image-codecs-bmp-resolution
image-codecs: BMP keeps its resolution in the header's pixels per metre
2026-11-16 05:45:26 -05:00
ljkx 7adcc9a6c2 image-codecs: BMP keeps its resolution in the header's pixels per metre
A BMP stores its resolution in biXPelsPerMeter and biYPelsPerMeter
(BITMAPINFOHEADER and later). The image crate writes 0 there and nothing
read the fields, so a 300 ppi image saved as BMP reopened at 72 ppi and an
opened BMP's resolution was lost (storytold/photocraft#13630).

decode now reads the fields into Metadata::dpi, encode writes
Metadata::dpi into them whatever embed_metadata says, and
caps(Format::Bmp).dpi is true. encode_bmp_indexed_with_dpi is the palette
writer with a resolution; encode_bmp_indexed keeps its signature and output.
2026-11-16 10:05:03 +01:00
FredApps e8aed7cfa6 image-codecs: find the JPEG EXIF APP1 by walking segments and bound the copy by its length
An Exif signature inside a COM segment was taken for the EXIF APP1, and the copy was checked
only against the end of the file, so a replacement longer than the APP1 overwrote the next
marker. Walk the header segments to the first EXIF APP1 and copy only within its declared length.
2026-11-16 08:30:28 +01:00
FredApps 3c78b4d670 Merge remote-tracking branch 'origin/main' into w1646
# Conflicts:
#	crates/image-codecs/src/codecs/jpeg.rs
#	crates/image-codecs/src/lib.rs
2026-11-16 06:48:43 +01:00
FredApps a499742a93 Merge pull request #1779 from storytold/image-codecs/jpeg-stored-inks
feat(image-codecs): read four-component JPEGs as stored inks
2026-11-16 04:48:49 +01:00
FredApps 2f10c9389e Merge pull request #1782 from storytold/image-codecs/jpeg-zune-panic
fix(image-codecs): read the JPEGs zune-jpeg panics on with craft-jpeg
2026-11-16 04:08:51 +01:00
FredApps 1b00186ae0 Merge pull request #1687 from storytold/codex/shared-font-plan-cache
Share per-face shaping plan cache
2026-11-16 04:01:15 +01:00
FredApps 9baecfa4a1 Merge origin/main; route frames zune-jpeg may panic on to craft-jpeg where panics abort
On panic = "abort" targets (wasm32) the catch_unwind fallback can't run, so
frames whose first component is sampled below the frame's largest factors
go to craft-jpeg before zune-jpeg is called.
2026-11-16 02:54:50 +01:00
Dylan M. Taylor 5ac7c9664c Merge pull request #1778 from storytold/fix/rav1e-threading
Forward opt-in threading to rav1e encoder dependencies
2026-11-15 20:53:17 -05:00
FredApps c28356d400 Merge pull request #1660 from storytold/codex/legacy-exif-orientation
Share legacy EXIF summary and preserve PNG orientation
2026-11-16 02:48:31 +01:00
FredApps 5b5f42961c Merge pull request #1672 from storytold/codex/sunraster-main-reconcile
craft-image-codecs: add opt-in Sun Raster reader and writer
2026-11-16 02:41:41 +01:00
FredApps 4a70763629 fix(image-codecs): refuse JPEG inks of frames too large for their scan data
zune-jpeg allocates its whole output before reading a scan, so
decode_jpeg_inks now applies decode's scan-data guard (one byte for every
2048 pixels, counted on scan data, not APP padding) first. The comparison
test's noise is computed in u64, so it doesn't overflow on 32-bit targets.
2026-11-16 02:39:34 +01:00
FredApps 832883b5b4 Merge pull request #1755 from storytold/image-codecs/probe-size-png-jpeg-tiff
image-codecs: probe PNG, JPEG and TIFF sizes from the header
2026-11-16 02:38:50 +01:00
FredApps 7d1d64fc46 Merge remote-tracking branch 'origin/main' into w1687
# Conflicts:
#	crates/font-catalog/src/tests.rs
2026-11-16 02:31:10 +01:00
vangel76 7c34335afb Merge remote-tracking branch 'upstream/main' into perf/dds-bc45-1766 2026-11-16 01:34:47 +01:00
vangel76 39e1d41af7 DDS: refuse premultiplied-alpha DX10 textures
The DX10 header's alpha mode (miscFlags2, low three bits) was never
read, so RGBA, BGRA, BC2 and BC3 files marked premultiplied were read
as straight alpha. They are refused as Unsupported, like the legacy
DXT2/DXT4 FourCCs. Alpha modes 0, 1, 3 and 4 and the formats without
alpha are unchanged.
2026-11-16 01:34:20 +01:00
FredApps fc1801a3aa Merge remote-tracking branch 'origin/main' into image-codecs/jpeg-zune-panic 2026-11-16 01:33:19 +01:00
Dylan M. Taylor d99d0d3f9d Merge main preserving AVIF threading and SGI features 2026-11-15 19:32:43 -05:00
FredApps 12fdc6571f Merge remote-tracking branch 'origin/main' into w1672 2026-11-16 01:27:27 +01:00
FredApps 1b71cd1c18 Merge pull request #1667 from storytold/codex/sgi-main-reconcile
Reconcile SGI codec with merged JPEG-LS support
2026-11-16 01:26:24 +01:00
FredApps a5a713d2e6 Merge remote-tracking branch 'origin/main' into image-codecs/jpeg-stored-inks 2026-11-16 01:21:38 +01:00
FredApps 3d09cb9ab9 Merge remote-tracking branch 'origin/main' into w-r-codex/legacy-exif-orientation 2026-11-16 01:15:06 +01:00
FredApps 159d7134d0 fix(image-codecs): read the JPEGs zune-jpeg panics on with craft-jpeg
zune-jpeg 0.5 asserts in its upsampler on some subsampled four-component
frames whose first component isn't the largest. decode now catches that
panic and reads the file with craft-jpeg, as it reads arithmetic-coded and
12-bit files. Refs #778.
2026-11-16 01:13:19 +01:00
FredApps 2d4b8b8ecd Merge pull request #1679 from storytold/codex/avif-source-depth
Expose source bit depth from AVIF decode
2026-11-16 01:11:58 +01:00
FredApps a61b1ad53c fix(image-codecs): JPEG inks of frames zune-jpeg panics on are an error 2026-11-16 01:05:44 +01:00
FredApps aa9ecc2be4 Merge pull request #1668 from storytold/codex/shared-raw-tiff-hint
Share legacy TIFF camera RAW classification
2026-11-16 00:54:25 +01:00
FredApps d0bba656d1 Merge remote-tracking branch 'origin/codex/legacy-exif-orientation' into w-1613
# Conflicts:
#	crates/image-codecs/src/lib.rs
2026-11-16 00:53:34 +01:00
FredApps 927eabc6e6 feat(image-codecs): a JPEG's declared size from its headers, as zune-jpeg reads them 2026-11-16 00:52:35 +01:00
FredApps a6c3feafd9 Merge remote-tracking branch 'origin/codex/legacy-exif-orientation' into w-1668 2026-11-16 00:50:40 +01:00
FredApps 2c2fcd1a28 image-codecs: cover the legacy Sony lossless YCbCr rule and skipped directories 2026-11-16 00:50:39 +01:00
FredApps 473753b58c feat(image-codecs): read four-component JPEGs as stored inks
A jpeg_inks module for apps that keep a CMYK JPEG's inks the way zune-jpeg
readers gave them: every four-component file taken as Adobe-inverted, YCCK
turned into CMYK as libjpeg does (truncating), only the 8-bit Huffman frames
zune-jpeg decodes (arithmetic-coded and 12-bit files are refused), within
Limits. Also the frame's component count and the assembled ICC profile from
the headers alone. Refs #778.
2026-11-16 00:44:58 +01:00
FredApps 010d1c1f00 Merge remote-tracking branch 'origin/main' into image-codecs/probe-size-png-jpeg-tiff
# Conflicts:
#	crates/image-codecs/src/lib.rs
2026-11-16 00:38:11 +01:00
FredApps 4d4a2c1726 Merge remote-tracking branch 'origin/main' into w-codex/legacy-exif-orientation 2026-11-16 00:26:49 +01:00
Dylan M. Taylor 1c39341f96 Forward opt-in threading to rav1e encoder dependencies 2026-11-15 18:24:32 -05:00
FredApps 947dc5fb0e Merge pull request #1630 from storytold/codex/shared-tiff-inspection
Share first-directory TIFF inspection
2026-11-16 00:05:27 +01:00
FredApps f749643b01 Merge pull request #1603 from storytold/codex/raster-probe-limits
Expose bounded stored raster dimensions
2026-11-16 00:01:21 +01:00
vangel76 c27333683a DDS: time decoding a 30 MP texture too
An ignored test beside the encode timings: the best of five decodes of
the same texture written with each compression. It uses only the API
the reader had before, so it runs on the old code for comparison.
2026-11-16 00:00:28 +01:00