Commit Graph
230 Commits
Author SHA1 Message Date
BFlat ffdb249cbe Merge pull request #3322 from dotCooCoo/fix/png-borrow-icc-profile
image-codecs: borrow the ICC profile and EXIF in the PNG header
2026-11-26 10:27:00 +07:00
BFlat 4a078fdac1 Merge pull request #2723 from dotCooCoo/fix/jpegls-restart-marker-after-segment
image-codecs: reject a JPEG-LS restart marker that follows another segment
2026-11-26 10:11:33 +07:00
BFlat 273186cb47 Merge pull request #2709 from dotCooCoo/feat/image-codecs-display-srgb
image-codecs: convert an image's ICC or CICP colors for display
2026-11-26 10:11:11 +07:00
BFlat aa19b389ac Merge pull request #2616 from dotCooCoo/feat/image-codecs-into-rgba8
image-codecs: checked RGBA8 and RGBA16 conversions, and into_rgba8 without a copy
2026-11-26 10:05:47 +07:00
BFlat 4363011a8b Merge pull request #2607 from dotCooCoo/feat/image-codecs-encode-borrowed-rgba8
image-codecs: encode a PNG from borrowed RGBA8 pixels
2026-11-26 10:05:07 +07:00
BFlat 749f21db40 Merge pull request #2597 from dotCooCoo/feat/image-codecs-input-cap
image-codecs: read a file or stream into bytes with a size cap
2026-11-26 10:03:33 +07:00
dotCooCoo a409ba1f32 Merge main into fix/png-borrow-icc-profile 2026-11-25 14:17:24 -08:00
Elvis33LE 2b7d18f1fb deps: migrate craft-image-codecs to jpeg-encoder 0.7.1 2026-11-25 22:35:17 +01:00
aiongg 3a567445fe Merge remote-tracking branch 'upstream/next' into test-speed-3 2026-11-25 01:55:58 +00:00
aiongg d402a1d71b Gate-sized cases for slow non-UI tests; full sizes and every case nightly
Boundary tests set by a production constant check a small limit through a
private seam that takes it (b64 decode, drawingml table normalize, openpgp
verify), with the real constant nightly; captions and jbig2 check their
full-size boundaries nightly. Sweeps run every divisor-th case at the gate
(develop balanced highlights and thin line, jpeg low-memory tokens, png
streamed rows, mxf extreme fields, pdf crypt proptests), the fax bomb guard
page is wider and shorter, the resample bound pulls a shorter block, the nef
measured frames are read through probe_info, and local tone compares 64 and
256 pixels.
2026-11-25 01:32:48 +00:00
aiongg 878b4ee811 image-codecs tests: the gate flips and overwrites one value per sampled byte, rotating 2026-11-24 22:33:06 +00:00
aiongg 79c5c887ae tests: is_multiple_of for the gate-sample strides 2026-11-24 20:34:27 +00:00
aiongg cbe6812a02 craft-image-codecs tests: smaller bomb-guard, PNG and DDS inputs, sampled fidelity sweep 2026-11-24 19:48:38 +00:00
dotCooCoo d28ad274b3 image-codecs: borrow the ICC profile and EXIF in the PNG header
The PNG writer copied the caller's ICC profile, and the exported EXIF,
into new buffers before writing the header. Each tagged save allocated a
second profile-sized buffer that could abort the process when memory ran
short. The header now borrows the profile, and borrows the EXIF whenever
export_exif returns it unchanged.
2026-11-23 23:58:58 -08:00
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
dotCooCoo 5d55b9994a image-codecs: convert untagged 16-bit and float RGB without rounding to 8 bits
For an RGB image with no source profile and a display other than sRGB,
`to_display_rgba8` rounded the samples to RGBA8 and then converted them
from sRGB, which lost precision and clipped float values before the
transform. It now converts the samples through the sRGB profile directly,
so the result matches the same image tagged with sRGB. Gray, CMYK and Lab
images without a profile still go through their `to_rgba8` values.
2026-11-20 17:55:32 -08:00
dotCooCoo fcf08f47ef image-codecs: correct the prefix length that detect documents for FF D8
For a buffer of only `FF D8`, `detect_prefix` answers `NeedBytes(4)`,
a 4-byte prefix that includes the SOI, not 4 bytes after it.
2026-11-20 17:16:57 -08:00
dotCooCoo 8b2268a898 image-codecs: AVIF matrix 12 reads unspecified primaries as BT.709
Chromaticity-derived reconstruction (matrix 12) took Kr and Kb from the
raw primaries code, so primaries 2 got BT.2020 weights while the HLG gain
in `cicp::linearize` read them as BT.709. Reconstruction now reads
unspecified primaries as BT.709 too, so a file tagged 2 decodes the same
as one tagged 1. Explicit BT.2020 keeps its weights.
2026-11-20 17:13:37 -08:00
dotCooCoo 0af8630bfb image-codecs: HLG with unspecified primaries uses BT.709 luma weights
The display conversion reads CICP primaries 2 (unspecified) as BT.709,
but the HLG gain in `to_display_rgba8` and in `cicp::linearize` took
BT.2020 luma weights for it, so a chromatic HLG pixel with unspecified
primaries was shown differently from the same pixel tagged BT.709, and
differently again after the HEIF and AVIF readers decoded it to linear
light. Both paths now read unspecified primaries as BT.709 when they
pick the weights. Explicit BT.2020 primaries keep BT.2020 weights.
2026-11-20 15:50:46 -08:00
dotCooCoo 32bba41a91 image-codecs: reject a JPEG-LS restart marker that follows another segment
While a restart interval is in effect, the decoder now rejects a restart
marker anywhere outside a scan's data, including one that comes after a
comment or another segment. Before, only a marker directly after the scan
was rejected, and one after a comment was skipped and the image decoded.
With an interval of 0 a stray restart marker is still skipped.

`detect` documents that a buffer of only `FF D8` matches no format, and
the tests check the error kind of a malformed DRI segment and a DRI change
between the component scans of an RGB file.
2026-11-20 15:47:26 -08:00
dotCooCoo 89ae139a45 image-codecs: convert an image's ICC or CICP colors for display
Image::to_rgba8 changes only the layout and sample type, so an app that
shows the result as sRGB draws a Display P3, Adobe RGB or BT.2020 picture
with the wrong colors.

With the new `cms` feature, Image::source_profile returns the profile
that describes the samples (the embedded ICC profile, or for an RGB
image without one, the profile of its CICP description), and
Image::to_display_rgba8 converts the pixels through craft-cms into a
display profile the caller passes. An image with neither is treated as
sRGB. PQ and HLG samples are decoded to linear light first and clipped
at diffuse white. The output is checked against Limits and reserved
before conversion, and 16-bit and float images are converted in bands.
2026-11-20 14:48:33 -08:00
dotCooCoo 14a5e7ed05 image-codecs: test that read_bounded reads one byte past its cap
A finite input longer than the cap fails with FileTooLarge and leaves the reader at the cap plus one byte.
2026-11-20 10:56:48 -08:00
dotCooCoo c20769e3cc image-codecs: checked RGBA8 and RGBA16 conversions, and into_rgba8 without a copy
Image::try_to_rgba8 and Image::try_to_rgba16 check the output against
Limits and reserve it with try_reserve_exact before any pixel is
converted, as Image::to_rgba_f32 does. A gray image is a quarter of its
RGBA8 copy, so a decode that fits the budget could still allocate past
it when converted. Sources other than U8 and U16 are converted one pixel
at a time, without the whole-image f32 buffers.

Image::into_rgba8 consumes the image and returns the pixel buffer of an
RGBA8 image as it is. A caller that decodes and then needs RGBA8 no
longer holds the decoded image and a copy at once.

to_rgba8 and to_rgba16 convert the pixel data only, without cloning the
image's metadata first.
2026-11-20 10:42:06 -08:00
dotCooCoo a6997e9532 image-codecs: encode a PNG from borrowed RGBA8 pixels
encode_png_rgba8 writes interleaved 8-bit RGBA pixels as a PNG from a
borrowed slice. encode takes an Image, which owns its buffer, so a
caller holding pixels in a frame or a shared buffer had to copy the
whole image before saving it. The output is the same as encode of an
Image with the same pixels, no ICC profile and default metadata. A
buffer whose length is not width * height * 4 is rejected with
InvalidImage.
2026-11-20 10:40:20 -08:00
dotCooCoo 2d5b96929b image-codecs: read a file or stream into bytes with a size cap
The decoders take a byte slice, and Limits bound only the decoded image,
so a caller had to cap and read the input itself. read_bounded(reader,
max_bytes) reads at most one byte past max_bytes and fails with
ErrorKind::FileTooLarge for longer input, including a file that grows
after its size was checked and a stream with no end.
2026-11-20 10:34:27 -08: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