Commit Graph
5896 Commits
Author SHA1 Message Date
.CooCoo 95cd2c0eb7 Add craft-color-transform: RGB spaces, white balance, OkLab, tone curves and PQ tone mapping (#1995)
* Add craft-color-transform: RGB spaces, white balance, OkLab, tone curves and PQ tone mapping

craft-color-transform builds on craft-color. It holds RGB spaces from
primaries and a white point with Bradford adaptation, white balance by
correlated color temperature and tint, OkLab and OkLCh for any RGB space,
monotone tone curves and 1D lookup tables, and the BT.2408-8 Annex 5 EETF
with a maxRGB tone map. The per-pixel functions take f32 and do not
allocate, and the crate builds for wasm32-unknown-unknown.

Moved from StudioCraft's craft-color-transform
(blamejs/StudioCraft crates/craft-color-transform). The README names the
LightCraft and FilmCraft modules parts of it started from.

* Color transform: compose, interpolate and invert at extreme values

Lut1::compose samples the densest grid of at most MAX_LUT entries that holds both tables' points, so a short inner table, or one that crosses an outer peak between its own points, keeps the outer table's points to within one grid step. Lut1::eval weights the two entries in f64, so entries as far apart as -f32::MAX and f32::MAX no longer give NaN or infinity. MonotoneCurve::new compares the tangent pair's length with 3|d|, so a subnormal secant next to a normal one no longer gives a NaN tangent. Mat3::inverse divides the matrix by its largest entry before taking the determinant, so diag(1e110) and diag(1e-200) invert. OkLab::for_space falls back to XYZ_TO_LMS when a matrix has no inverse or an entry beyond f32.

* Color transform: build the matrix arithmetic on craft_cms::math

craft_cms::math gains the two hardened functions the color transforms
need, and craft-color-transform calls them instead of carrying its own
copies.

- math::inverse divides the matrix by its largest entry before taking
  the determinant, so a matrix whose own determinant overflows or
  underflows still inverts, and it returns None for NaN, infinite or
  all-zero input and for an inverse beyond f64. math::invert keeps its
  absolute 1e-12 floor, which profile construction uses to validate ICC
  matrices.
- math::bradford_checked returns None when a white's cone response is
  not finite or not above 0, or the ratios overflow. math::bradford
  still divides without the check.
- math::BRADFORD is public.
- Mat3::mul, apply, determinant and inverse, Xy::to_xyz, BRADFORD and
  bradford_xyz call craft_cms::math.
- oklab::lms_matrices gives OkLab::for_space's matrices in f64.

* Color transform: keep the EETF's black lift rising for a high target black

The BT.2408 Annex 5 lift minLum * (1 - E2)^4 has a slope of 1 - 4 minLum
at E2 = 0, so a target black above a quarter of the normalized range
made the output fall near black, and it raised the peak well above the
target peak.

The lift is now minLum * (1 - E2 / r)^k with r = max(T, min(1, 2 -
4 minLum)) and k = min(4, r / minLum), where T is the top of the output
(the smaller of maxLum and 1). It equals the Annex's lift up to minLum
0.25, keeps the output rising, changes continuously with the target
black, and from minLum 0.5 reaches 0 at the top of the output. A target
black above the source peak reads as the source peak.

* Color transform: state the composition bound for the fallback grid
2026-11-18 15:35:09 -05:00
Tex Jernigan db9e24391a craft-develop-model and craft-geom: develop settings and crs: import, from LightCraft (#1132)
* craft-geom and craft-develop-model: develop settings and crs: import, from LightCraft

craft-develop-model is lightcraft-develop (settings, controls, presets,
segmentation masks, process versions) plus the crs: import from
lightcraft-engine (crs.rs, crs_masks.rs). craft-geom is lightcraft-geom,
which the model and the coming develop pipeline both need. Step 3 of #587.

* craft-develop-model, craft-geom: review fixes to copy, presets, section reset and crs: import

Copy and presets: to_json_for_merge states every setting the stored JSON
leaves out at its default, so copying a group turns HDR, the camera's local
tone and Lens Blur's optional settings off on the target, and a preset at an
amount starts from them. A preset at no amount adds no mask, and its Lens
Blur focus mask follows its mask to the id the photo gives it.

Reset and range: reset_section resets the sliders of point colours and red
eyes, Upright with its guides, and the two Optics switches. Settings from
outside the app keep the list sliders in range. is_unedited counts a chosen
white balance as an edit.

crs: import: a brush dab that is not a finite number is dropped instead of
failing the whole packet, brush runs that differ in MaskInverted stay two
components, RetouchInfo is read only without RetouchAreas, and an XMP preset
keeps its masks. SegMask::from_logits does not overflow on an absurd side.

craft-geom: Homography::from_quads solves a mapping that sends the origin
to infinity, by solving again about the middle of the source quad.

Docs: the links to LightCraft's light-v3.md and grain.md point at that
repository, and xmp-interop.md says when the older fields are read. The
README lists what now differs from LightCraft.

* craft-develop-model, craft-geom: second round of review fixes to crs: import, mask grids, crop and quads

A range mask with a number that is not one failed the whole merge; a straight legacy ToneCurve and a
photo's switched-off masks or spots were left unsaid, so the photo kept what it had; a mask grid of a
side past the limit was cut to 32 bits; a crop restored under a new angle could reach outside the
photo; a quad mapping onto a collapsed quad solved to a matrix that does not map it.
2026-11-18 15:35:02 -05:00
mmazzieriandMauro Mazzieri 5bd7eb9e88 craft-rtf: read text boxes and drawing shapes from \shpinst (#2059)
Ported from storytold/wordcraft#6242 (issue storytold/wordcraft#6212), written before the RTF reader
moved here. Rectangles, ellipses, triangles, diamonds, block arrows and text boxes are read from
the shape's properties (position, size, wrap, fill, line, text); the \defshp picture Word writes
after a shape it read, also inside \shppict, is not imported as a second copy.

Co-authored-by: Mauro Mazzieri <mauro.mazzieri@talete.net>
2026-11-18 15:31:52 -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
ljkx 68df8bf16c fix(rtf): list levels keep their number format, start and level text (#2085) (#2259)
The `doc` reader kept only "numbered or not" for each level of an RTF
list table and gave every list paragraph start 1 and no label, so every
numbered list read as 1., 2., 3.

Each `\listlevel` now keeps its number format (`\levelnfc`/`\levelnfcn`,
the MSONFC codes, as the Word 97 reader maps them), the number of its
first item (`\levelstartat`, held to Word's 0..=32767) and its
`\leveltext`, read in a destination of its own and bounded to 256
characters. A list paragraph's `ListInfo` gets the level's start and a
label from `Label::of_level` (placeholders 0 to 8 as %1 to %9; a bullet
level's character as its bullet). A level without level text keeps no
label, as before.
2026-11-18 15:30:54 -05:00
ljkx cec20449a2 fix(audio): an empty WAV data chunk before a LIST chunk is no audio (#2123) (#2246)
A `data` chunk of size 0 counted as empty only when the RIFF size matched
the file. A writer that appends a `LIST` chunk after writing the RIFF size
leaves it stale, so the reader took the file for an unfinished recording
and decoded the `LIST` chunk's bytes as samples (8 frames of noise instead
of none).

A size-0 `data` chunk is now also empty when whole chunks follow it and the
first one has an id that follows audio (LIST, bext, cue, JUNK, ...). A
recording that was never finalised (PCM after the header) and bytes that
only start like a chunk still decode as audio.
2026-11-18 15:30:49 -05:00
Michael Higgins d851c9b2e3 craft-pdf: a rebuilt xref keeps the generation-0 object the page draws (cos) (#2240)
When the cross-reference data is rebuilt from object headers, the index
was keyed by object number alone, so a later `N 1 obj` replaced
`N 0 obj` while the renderer still drew `N 0 obj` under `N 0 R`. cos
read the page's object as null and a full save wrote null
(storytold/pdfcraft#6759).

Each number now keeps its object by the renderer's rule: the last real
`N 0 obj`, else the last header as a generation-0 stand-in. Where a
number has headers of several generations, a bounded walk from the
trailer gives the slot to the one generation the document reaches,
when it reaches one only, so a reused number such as PDFBOX-3785's
`202097.pdf` keeps its page. A trailer /Root is ranked by its own
generation's header, and a slot whose object stream supplies indexed
members stays. What one slot cannot hold goes to the repair log, and
Document::rebuilt_with_unsettled_generations() says when a save could
differ from what the renderer drew.

Port of storytold/pdfcraft#6767, which can't land in pdfcraft since cos
moved here.
2026-11-18 15:30:17 -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
Diego Chagas f57bbca24f jxl: bound brob metadata boxes before jxl-oxide inflates them (#2134)
jxl-oxide decompresses brob (Brotli Exif/XMP) boxes into a buffer its AllocTracker
does not count, so a 54-byte box expanded to 64 MiB of XMP and a larger one can ask for
gigabytes before any pixel limit applies. decode now inflates every brob box under one
8 MiB budget per file, rewrites it as the plain box it wraps and drops boxes past the
budget, nested or broken ones. Files without a brob box are not copied.
2026-11-18 15:25:26 -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
Hamza Naveed bd5c93cf50 craft-odf: taking inline items out of a flat document is linear (#2219) (#2237)
take_out searched the whole rest of the document for the next picture and the next inline
object on every item, so a document with many of one kind and none (or few) of the other cost
items × size. It now keeps where the next of each is and searches for a kind again only once
it has been passed. The output is the same.
2026-11-18 15:23:21 -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
aiongg 38429defb8 Merge pull request #2082 from davidmann4/perf-frame-cost
Menus: Help entries only while Help shows, mnemonics once per level, chords without allocating (photocraft#15493)
2026-11-18 15:12:05 -05:00
Phil HartandClaude Opus 5.5 2393b1f16f craft-raw: decode two-field Coolpix NEFs (E5400, E5700 CYGM, E8400, E8800) (#2235)
Ported from storytold/lightcraft#672, whose decoder code now lives here.
Some CCD Coolpix bodies store two interlaced fields one after the other in
one tight 12-bit strip. For the measured bodies, in their measured legacy
layout (binary maker-note version 0.2.0.0, compression 1, one strip of
w*h*1.5 bytes), the fields are interleaved in the model's field order. The
E5700's CYGM mosaic becomes approximate linear RGB with fixed gains.
Masked columns are judged on the stored rows, so the header probe and the
full decode agree. Other files keep their stored rows.

Checked on 527 NEF/NRW samples: only the six E5400/E5700/E8400/E8800 files
(and four synthetic legacy-layout fixtures) change; the other 517 decode
bit-identically.


Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:03:26 -05:00
Phil HartandClaude Opus 5.5 0976e3fd19 craft-raw: Kelvin presets for more CR2, CR3, PEF and RW2 raws (#2234)
Reads the camera's white-balance presets as a Kelvin curve where the
decoders gave none:
- CR2 ColorData versions 1 to 12 (5-word records), version 10 at either
  of its two layouts, picked by the Daylight record's 5200 K;
- CR3 ColorData versions 16-19, 32-34, 48 and 64-66;
- PEF maker note 0x0221 (entries of 53190 - K and the red/blue
  multipliers);
- RW2/RWL/RAW tag 0x0027: the D55 and 3200 K studio tungsten
  multipliers as a neutral pair with their chromaticities
  (KelvinPresets::from_neutral_lights / neutral_lights).
Ported from storytold/lightcraft#2527.


Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:02:12 -05:00
Phil HartandClaude Opus 5.5 ccabfee3b5 craft-raw: no frame floor for tiny lossless JPEG tiles (#2232)
A DNG tile's frame may hold at most twice the tile's samples and a Sony
quad tile's at most the tile's samples, with no 65,536-sample floor. The
floor let each of many tiny tiles decode and keep a frame far larger than
the tile budget counts (storytold/lightcraft#4024). A DNG tile also drops
the surplus capacity of a larger frame after the resize.


Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:00:30 -05:00
David Mann 650979426d Merge pull request #2067 from davidmann4/perf-menu-hover-lag
Menus: test that the highlight moves to the next row in the frame the pointer reaches it (photocraft#15477)
2026-11-18 20:45:44 +01:00
FredApps c62d548b6b psd: expose bounded recovering tagged descriptor prefixes 2026-11-18 20:36:57 +01:00
Dylan M. Taylor 2466fd7ad8 Reject nonfinite promoted PostScript decimal integers (#2256) 2026-11-18 14:05:54 -05:00
David Mann e5a16290fd Merge pull request #2121 from davidmann4/input-reply-at-pass-end
Control channel: answer injected input with the pass that ran it, not one pass later (photocraft#15493)
2026-11-18 20:04:55 +01:00
David MannandClaude Opus 5.5 37f0d16764 menu bar tests: the two new tests run as Linux, like the rest of the file (macOS has no in-window bar)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 20:02:00 +01:00
David Mann e380b20809 Merge pull request #2136 from davidmann4/fix/window-edge-drag-leaves-window
A press whose pointer left the window still drags: window edges resize when pulled out (#2132)
2026-11-18 19:54:12 +01:00
David Mann a8cec754bf Merge pull request #2099 from davidmann4/fix/photocraft-12517-column-only-panels
dock: panels that dock only in dock columns (photocraft#12517)
2026-11-18 19:53:15 +01:00
David Mann 90ca881c87 Merge pull request #2066 from davidmann4/fix-floating-panel-drag
Floating panel windows follow the pointer when dragged (photocraft#15478)
2026-11-18 19:52:53 +01:00
David Mann d7c73383be Merge pull request #2065 from davidmann4/fix/task-bar-grip
Task bar: grip on the members' line, one floating surface (photocraft#15479)
2026-11-18 19:52:39 +01:00
el-j 6a41b76ca5 Merge main into feat/video-mjpeg-frame 2026-11-18 19:40:40 +01:00
FredApps 62f7a7e477 Merge pull request #2244 from FredApps/fix/786-psd-tysh-prefix
psd: expose bounded raw TySh text prefix
2026-11-19 01:29:20 +07:00
FredApps a7ff7b31ae Merge pull request #2241 from FredApps/fix/786-psd-section-recovery
psd: add opt-in section-divider blend recovery
2026-11-19 01:29:08 +07:00
David Mann 453210d8d0 Merge pull request #1122 from davidmann4/craft-flags-review
fix(flags): the review findings on craft-flags (#1119)
2026-11-18 19:29:05 +01:00
David Mann 9824f9e009 Merge pull request #2199 from davidmann4/repin-craft-ai-agents
Pin craft-ai-agents to a commit on craft-ai-integrations main (#2198)
2026-11-18 19:28:35 +01:00
FredApps 44086e9c58 Merge pull request #2206 from FredApps/fix/786-psd-vector-records
psd: expose path record knot decoding for consumer adapters
2026-11-19 01:06:18 +07:00
David MannandClaude Opus 5.5 367d2a3e65 automation tests: name the polling fixture's pass log (clippy type_complexity)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 18:38:41 +01:00
Dylan M. Taylor f4b5fdebc1 Exercise valid delegated OCSP evidence and isolated rejection policies (#2249) 2026-11-18 12:36:15 -05:00
David Mann 3e624f9930 Merge remote-tracking branch 'origin/next' into HEAD 2026-11-18 18:35:50 +01:00
David MannandClaude Opus 5.5 b2612c91dc Menus: test that the highlight moves to the next row in the frame the pointer reaches it
A menu row's highlight comes from the LEAD flag rule, which resolves without easing, and
the popup makes the row under the pointer active before its rows run. The new test pins
both: the frame that moves the pointer onto the next row paints that row's full highlight
and none on the row it left, with no time passing. It fails if the active row follows the
pointer a frame late, or if the highlight moves onto the eased hover mix (80 ms).

Fixture::frame_shapes_with(events) returns what the frame that took the input painted.

Part of photocraft#15477.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 18:31:34 +01:00
David Mann 161ea90ec7 Merge remote-tracking branch 'origin/next' into HEAD 2026-11-18 18:30:36 +01:00
David Mann c4c4355e48 Merge remote-tracking branch 'origin/next' into HEAD
# Conflicts:
#	crates/ui-contract/src/runtime/windows.rs
2026-11-18 18:27:21 +01:00
David Mann 507060a883 Merge remote-tracking branch 'origin/next' into HEAD 2026-11-18 18:27:11 +01:00
David Mann 987933fb1f Merge remote-tracking branch 'origin/next' into HEAD
# Conflicts:
#	crates/menu/src/bar.rs
#	crates/ui-widgets/tests/it/menu/bar.rs
2026-11-18 18:26:56 +01:00
David Mann 7429d8cdb1 Merge remote-tracking branch 'origin/next' into HEAD 2026-11-18 18:26:31 +01:00
David Mann 6f6426960f Merge remote-tracking branch 'origin/next' into HEAD 2026-11-18 18:26:27 +01:00
David Mann 1d5ac4ba5c Merge remote-tracking branch 'origin/main' into HEAD 2026-11-18 18:24:33 +01:00
David Mann 679a499cc6 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	Cargo.toml
2026-11-18 18:24:12 +01:00
aiongg 8a68633768 Merge pull request #2073 from aiongg/themecraft-wave1
ThemeCraft wave 1: theme edits, library save, region theming, icon packs, craft-theme-editor crate
2026-11-18 12:22:56 -05:00
aiongg e5f682a36d Merge pull request #2236 from aiongg/ci-speed
ci: cache after the build, rust-lld on Windows, slowest tests first
2026-11-18 12:21:07 -05:00
Dylan M. Taylor bc4aae37bb Merge pull request #2245 from storytold/fix/ocsp-certificate-wrapper-20261118
fix(pkcs7): read standard OCSP certificate sequence wrappers
2026-11-18 12:12:13 -05:00
Dylan M. Taylor c51ed21b27 Merge pull request #2162 from storytold/fix/html-widthless-colgroup
craft-html: preserve cell-width fallback for widthless colgroups
2026-11-18 11:52:59 -05:00
FredApps 9af6a8e4a1 Merge remote-tracking branch 'origin/main' into fix/786-psd-tysh-prefix 2026-11-18 17:40:01 +01:00
FredApps d04bd2c4fb Merge remote-tracking branch 'origin/main' into fix/786-psd-section-recovery 2026-11-18 17:40:00 +01:00
FredApps 8ea89705a5 Merge main to inherit full Windows formatting repair 2026-11-18 17:39:45 +01:00