Commit Graph
206 Commits
Author SHA1 Message Date
aiongg cf35f7dbae Merge remote-tracking branch 'upstream/main' into next-sync-1123
# Conflicts:
#	Cargo.toml
#	crates/audio/src/track.rs
2026-11-23 01:29:52 +00:00
Terra854 1c137fea60 image-codecs: share bounded PNG sRGB metadata writing (#2941)
* image-codecs: share bounded PNG sRGB metadata writing

* png: reject legacy color chunks that conflict with sRGB
2026-11-23 03:38:34 +07:00
Dylan M. Taylor 49f38d0e30 tiff: expose plain RGBA16 without the raster facade (#3082) 2026-11-22 15:16:58 -05:00
Dylan M. Taylor e683cb299f Merge pull request #3067 from storytold/feat/778-strict-jpeg-orientation
jpeg: share strict EXIF orientation framing
2026-11-22 13:17:05 -05:00
DylanMTaylor 7e88389c8e Document legacy JPEG zero-marker handling 2026-11-22 12:20:57 -05:00
Dylan M. Taylor 983a116784 tiff: share the plain RGBA16 writer 2026-11-22 11:06:35 -05:00
Dylan M. Taylor e084f8c1f6 jpeg: share strict EXIF orientation framing 2026-11-22 11:04:24 -05:00
Terra854andFredApps 52d2560c18 image-codecs: share ISO-BMFF brand prefix framing (#2638)
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-22 18:45:42 +07:00
Terra854 e1d62d7e19 image-codecs: share PNG physical resolution writing (#2879) 2026-11-21 12:56:40 -05:00
Dylan M. Taylor c60e7a2006 image-codecs: expose raw PNG pHYs pixels_per_meter reader (#785) (#2865) 2026-11-21 11:39:45 -05:00
David MannandClaude Opus 5.5 1929e79ebb Merge storytold main into next (20 Nov, second sync)
Merges main at 8f92ed1334 (#2550 and the rest of main since the 20 Nov sync).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:38:55 +01:00
FredApps ab9f9a4a27 Merge pull request #2369 from storytold/perf/2218-raster
image codecs: consolidate integration tests
2026-11-20 18:33:50 +07:00
yoriswind b7cf916792 style: format DPX decoded budget assertion
(cherry picked from commit a874344ced)
2026-11-20 07:00:55 +01:00
yoriswind 0596a975ae Reduce temporary memory when decoding DPX and Cineon
(cherry picked from commit f08789c7a6)
2026-11-20 07:00:55 +01:00
yoriswind 4f31e9c33a Avoid widened sample buffers in eight-bit DPX export
(cherry picked from commit 23393d1def)
2026-11-20 07:00:49 +01:00
FredApps 051ec4fd62 Merge pull request #2389 from yoriswind/codex/shared-dpx-export-u8-r1
Avoid widened sample buffers in eight-bit DPX export
2026-11-20 12:36:48 +07:00
FredApps 54cb4af7e1 Merge pull request #2396 from yoriswind/codex/shared-dpx-decode-widen-r1
Reduce temporary memory when decoding DPX and Cineon
2026-11-20 12:31:20 +07:00
Dylan M. Taylor a7c6c9d61c image-codecs: extract JPEG and JP2 embedding probes (#2498) 2026-11-19 23:32:11 -05:00
FredApps 4041815638 Merge remote-tracking branch 'origin/next' into perf/2218-raster 2026-11-20 05:14:46 +01:00
Elvis33LE 4b4d5f7a9d fix(exr): stage contained data windows in display canvas (#2033) 2026-11-19 21:30:51 -05:00
aiongg b05c1c27f9 Merge storytold main into next (20 Nov sync) 2026-11-20 01:48:18 +00:00
Dylan M. Taylor 512a1b8e8b mesh, image-codecs: add clearcoat/sheen GLB, obj_with_mtl, and EXR chromaticities (#778) (#2466)
* mesh, image-codecs: add clearcoat/sheen GLB, obj_with_mtl, and EXR chromaticities (#778)

* fix(mesh): import Image and TextureRef in obj tests

* fix(mesh): construct Mesh via struct literal in gltf test
2026-11-19 19:50:59 -05:00
Dylan M. Taylor bc186ca719 image-codecs: keep first JFIF APP0 density in scan_metadata (#2422) 2026-11-19 14:51:45 -05:00
Dylan M. Taylor 41a9edd001 image-codecs: keep resolution probe fallback and container-only WebP EXIF scan (#2409) 2026-11-19 13:11:14 -05:00
aiongg ca58dfe6c9 Merge storytold main into next (19 Nov sync)
Merges main at d7c9632bfb.

- Cargo.toml: both sides' new workspace crates (next's font-subset, harfbuzz-subset-sys and
  host; main's gpu, gpu-null, gpu-providers and gpu-wgpu).
- crates/jpeg: next split lib.rs into modules; main's reduced-size decoding goes to them: the
  scaled IDCT, reconstruction and render_scaled to idct.rs, MAX_SHRINK, reduced_estimate and
  decode_reduced stay public in lib.rs. Main's new test added; the frame test next removed
  stays removed.
- crates/audio, crates/media: next builds the integration tests into the library's test
  executable (autotests off, tests/main.rs); main's new DSD and MPEG-TS mux tests are modules
  there behind their features instead of [[test]] targets, and the mux tests reach their shared
  helper module through the integration module.
- crates/media/src/matroska/track.rs: main's new FFV1 codec-parameter test added; the test
  modules next removed stay removed.
- crates/file-formats: main's JXL capability test, which asks the codec whether JXL reads,
  replaces next's interim check.
2026-11-19 16:22:24 +00:00
Dylan M. Taylor d7c9632bfb image-codecs: add jpeg_with_icc and jpeg_without_icc to jpeg_inks (#2400) 2026-11-19 10:53:18 -05:00
FredAppsandFredApps 30a568b97f image-codecs: expose raw BMP density probe (#2354) [skip ci]
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
2026-11-19 21:26:09 +07:00
FredApps dfe722af62 Consolidate related image tests 2026-11-19 13:05:37 +01:00
yoriswind a874344ced style: format DPX decoded budget assertion 2026-11-19 03:50:40 -08:00
yoriswind f08789c7a6 Reduce temporary memory when decoding DPX and Cineon 2026-11-19 01:50:21 -08:00
yoriswind 23393d1def Avoid widened sample buffers in eight-bit DPX export 2026-11-19 01:50:13 -08:00
Diego Chagas 401bf426a6 jxl: charge failed brob inflations, refuse large windows, walk boxes without a span list (#2275)
Follow-up to the brob budget:
- an over-cap or broken stream now charges the bytes it produced to the shared budget, so
  a file of many such streams cannot inflate the whole budget once per box;
- a Brotli header that declares a large window is refused before decoding (the decoder reserves
  its ring buffer up front, outside the output cap);
- boxes are walked one at a time instead of collected into a Vec of spans before the brob check.
image-codecs: document that JPEG XL ignores keep_orientation.
2026-11-19 00:11:50 -05:00
.CooCoo c39072d321 image-codecs: keep PrefixDetector tests within the prefix contract (#2277)
PrefixDetector::detect requires each call's bytes to start with the
previous call's bytes. Two integration tests passed a buffer that broke
that rule, so a detector that rechecks the SOI before resuming would
have failed them while still honoring the contract.

The tests now pass longer prefixes of one file and compare each answer
with detect_prefix on the same bytes. The check that a walk resumes at
the marker it stopped at stays in the jpegls unit tests, and a new unit
test checks that a walk that found a non-JPEG-LS frame header stays at
that marker.
2026-11-18 23:20:49 -05:00
aiongg e8e713ee26 Merge storytold main into next (18 Nov sync)
Merges main at 3b8e426a26.

- crates/ui: main's e-sign dialog (crates/ui/src/esign) moves to craft-cloud-ui beside the
  share dialog, behind craft-cloud-ui's esign feature; craft-ui forwards `esign` and
  re-exports the module.
- crates/proof: main's can_suggest_cased goes to affix/check.rs and its tests to
  affix/tests.rs (next split affix.rs); French wiring in lib.rs.
- crates/svg: main's validated resolver and raster validation stay under tree-render, which
  now also enables gif and image-webp; the shared image-codec helpers are gated on tree.
- craft-ai-agents: main's rev (craft-ai-integrations main), one entry.
- crates/craft: facade dependencies, features and re-exports for main's new crates.
2026-11-18 23:07:38 +00:00
.CooCoo b130ac1fa4 image-codecs: find the JPEG-LS frame header past 64 segments, and add detect_prefix (#2178)
* image-codecs: find the JPEG-LS frame header past 64 segments, and add detect_prefix

detect walked at most 64 marker segments looking for the SOF55 frame
header, so a JPEG-LS file with more segments before its frame header,
such as an ICC profile split over 255 APP2 segments, was reported as
JPEG. The walk now runs until it reaches a frame or scan header or the
end of the bytes. Each step moves forward at least one byte, so the walk
takes at most one step per byte.

detect also reported JPEG for a buffer that ended before the frame
header, which is what a caller that reads only the start of a file
passes. The new detect_prefix returns Detection::NeedBytes(n) in that
case, with the length the next step reads, and otherwise the answer
detect gives. The doc comment on detect now says that it needs the bytes
up to the frame header.

* image-codecs: walk each JPEG marker segment once when detecting in steps

detect_prefix walks the marker segments from the SOI on every call, so a
caller that reads exactly the length each Detection::NeedBytes asks for
walks the earlier segments again on each call. Over a file with many
small segments before its frame header, the total walk grows with the
square of the segment count.

The new PrefixDetector keeps the offset of the marker where its last
walk stopped and starts the next walk there. Its detect gives the same
answer and asks for the same lengths as detect_prefix, and
detect_prefix now runs a single step of a new PrefixDetector.

* image-codecs: read past a JPEG-LS restart interval segment and stop at FF 00

The JPEG-LS frame walk treated a DRI segment before the SOF55 frame header
as the end of the walk, so a file with one was detected and decoded as
JPEG. DRI now takes the length-prefixed path. The decoder accepts a 2-, 3-
or 4-byte interval of 0, reports a nonzero interval as unsupported, and
rejects other segment sizes as malformed.

`FF 00` after the SOI is a stuffed zero, not a marker, so the walk now ends
there instead of asking for a length field.

A PrefixDetector whose walk stopped at another frame header answers JPEG
for bytes that start with `FF D8 FF`, without walking from the SOI again.

* image-codecs: apply the JPEG-LS restart interval in effect at each scan

A later DRI with an interval of 0 turns restarts off again, and an
interval of at least the frame height puts a non-interleaved scan in
one interval with no restart marker. Both decode again. A nonzero
interval shorter than the frame height is still unsupported.

* image-codecs: reject a restart marker after a JPEG-LS scan of one interval

A restart marker comes only between two restart intervals. When the
interval in effect is at least the frame height, the scan is one
interval, so a restart marker after it, with or without fill bytes
before it, is now an error instead of being skipped.

Adds a test that a PrefixDetector starts each call at the marker where
its previous walk stopped.
2026-11-18 15:52:55 -05:00
.CooCoo 37724ad48d craft-image-codecs: lossy WebP encoding no longer copies the luma plane for every macroblock (#1975)
The VP8 encoder cloned the whole luma reconstruction before each
macroblock's B_PRED trial and restored it when a whole-block mode won,
so encoding P pixels copied about P^2/256 bytes. The trial writes only
the current macroblock, and the whole-block path writes every pixel of
that macroblock again without reading the trial's values, so the copy
and the restore are removed.

The output is byte-identical: a new test pins the SHA-256 of ten
encoded files (1x1 to 640x480, sizes that are not multiples of 16,
qualities 10 to 95) taken before the change, and decodes each with
image-webp. An ignored test prints encode times for 512 to 4096
squares; in release on one machine, 4096x4096 took 162.9 s before and
1.36 s after.
2026-11-18 15:51:10 -05:00
.CooCoo a19d58c5f6 dds: read R16G16 as red and green, and open 16-bit textures at 16 bits (#2124)
R16G16_UNORM stores a red and a green channel
(https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format),
but craft-dds read it as gray and alpha, so a two-channel normal map
opened with its green channel as transparency. It now reads as RGB with
blue 0, as BC5 and G16R16 channel masks already do. encode16 still
writes two-channel 16-bit pixels as R16G16; they read back as red and
green.

craft-image-codecs decoded every DDS at 8 bits. Texture::bits_per_channel
gives the widest stored channel, and textures wider than 8 bits (R16,
R16G16, R16G16B16A16, legacy FourCC 36, and channel masks with a 10- or
16-bit field) now open as U16 through decode16. craft-raster-codecs'
decode_levels does the same for every mip level.
2026-11-18 15:31:45 -05:00
Diego Chagas 7ff0f967db image-codecs: read JPEG XL through craft-jxl behind a jxl feature (#2135)
* image-codecs: read JPEG XL through craft-jxl behind a jxl feature

Format::Jxl reads when the non-default `jxl` feature is on (decode only, so the
encoder's jixel dependency is not built); without it JPEG XL is still detected and
opening one is an Unsupported error that says the build lacks it. Orientation is
applied by the decoder, so the Exif and XMP orientation become 1. ICC, Exif and XMP
come through; associated alpha is divided out; float files open as F32.

* image-codecs: skip JPEG XL in the one-pixel round trip

The encoder refuses images narrower than two pixels; with the jxl feature JPEG XL is a
read-and-write format, so the generic round trip reached it.
2026-11-18 15:26:57 -05:00
DJHoltkampandDJHoltkamp 0d8d8b9091 craft-image-codecs: refuse WebP animation frames that would panic image-webp (#2263)
For an animation frame that starts with an `ALPH` chunk, image-webp 0.2.4 decodes
the next chunk as VP8 whatever its FourCC, skips the size check it makes for frames
without alpha, and indexes the frame's buffers by the picture's own size. A picture
larger than its `ANMF` header, or a non-key frame (decoded as 0x0), panicked with
out-of-bounds indexing in `read_frame` and `fill_rgba`. image-webp also steps from one
frame to the next without the padding byte, so after an odd-sized `ANMF` chunk it
reads the next frame one byte early.

Before decoding, the container is walked for the first frame with alpha whose picture
is not a VP8 key frame of its header's size, and for the first odd-sized `ANMF` chunk.
That frame is refused like a damaged frame: `decode` (which reads frame 0) errors only
when it is the first, and `decode_webp_frames` keeps the frames before it with a
`Truncated` warning.

Found by fuzzing `decode_webp`; ported from storytold/photocraft#10473, which was
written before PhotoCraft's codecs moved here. The regression test panics without the
fix.

Co-authored-by: DJHoltkamp <4955429+DJHoltkamp@users.noreply.github.com>
2026-11-18 15:24:26 -05:00
82fc745154 image-codecs: PNG bounds its image on the IDAT data and reserves only what it can make (#2231)
* image-codecs: PNG bounds its image on the IDAT data and reserves only what it can make (lightcraft#3912)

The plausibility check measured the stored samples against the whole file
length, so ancillary chunks lifted the bound, and the decoder then reserved
the whole expanded output up front. A 1-bit 20000x20000 image is 50 MB
stored but 400 MB to 1.6 GB once expanded to 8-bit grey, RGB or RGBA, so
about 60 KB of IDAT reserved gigabytes.

- Bound the stored samples on the bytes of the first IDAT run (1032:1 plus
  1 MiB), not the file length.
- Reserve up front only what the IDAT data can inflate to; past that, grow
  the buffer as rows decode, at most doubling and never past the full
  output. A forged file fails on its first row; a real solid or sparse
  1-bit image that is past the ratio once expanded still decodes.
- Interlaced images decode into the whole zero-filled output in one go,
  so their expanded size is checked against the IDAT data.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc

* Fix Adam7 palette expansion bounds without allocating unvalidated output

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2026-11-18 15:14:45 -05:00
FredApps 7b8c1eccea Merge pull request #2041 from Terra854/codex/svg-integrity-hooks-review21
Share checked SVG image validation and DOM reuse
2026-11-18 09:15:11 +07:00
aiongg 4d22e6b958 Merge storytold main d6b5b16bbb into next (18 Nov sync)
- Workflows: main's per-crate layout, with next in the push triggers, Linux only for pushes to
  next, next's crate features (keymap egui, window and update ui) and test paths (crw samples and
  the pdf fixtures run inside the lib's test binary). The workspace gate keeps --keep-going and
  the facade-as-an-app clippy from next's ui.yml. Per-crate doc steps live in docs.yml, which also
  documents craft-ui, the ui-* crates, craft-doc and craft-pdf with every feature. docpath, i18n,
  print and ui workflows go, as on main. actions.lock lists docs.yml and theme.yml.
- Main's cloud and share UI (account, cloud, share, presence, the overflow menu and split button)
  lives in the new crate craft-cloud-ui as main wrote it; the craft-ui facade forwards share and
  cloud and re-exports account, cloud, share and presence, so craft-cloud-local builds unchanged.
- audio and media: main's new tests join tests/main.rs under their features.
- cms: main's new synth and FOGRA39 tests, with the fogra39() helper they use.
- nextest: no gpu group on unix; next's tests create no GPU device.
2026-11-18 01:22:22 +00:00
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
Terra854 6815dd6b7c Find JPEG sampling headers after marker padding 2026-11-18 04:58:02 +08:00
Terra854 6413cbb806 Guard SVG JPEG validation on panic-abort builds 2026-11-18 04:34:32 +08:00
Terra854 408ab93329 Preserve SVG siblings and share embedded-image validation 2026-11-18 04:01:51 +08: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