* fix(video): retain original footage for restore and comparison (#3059, #3060)
* Clamp original-frame inserts to the original stack; cargo fmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
flatten_to_surface (Flatten Image, Merge/Stamp Visible, Copy Merged)
composited a CMYK document in RGB and converted it back, turning K-only
black into four-colour black (K100 became C18 M11 Y12 K91) and shifting
other inks. Documents whose layers mix on their ink values are now
flattened from that composite (over white paper, no ink, for Flatten
Image); others are converted back through the document's own profile,
the one their layers were read through, rather than the built-in one.
The merged image of a CMYK PSD (what other applications show and
print) comes from the ink composite whenever the document's layers mix
on their ink values, so K-only black stays K-only there as in TIFF and
JPEG exports. Other documents keep the RGB composite converted through
the document's profile.
CMYK documents whose layers carry effects (drop and inner shadows,
glows, strokes, colour and gradient overlays, satin, bevel and emboss)
or knockouts now composite on their ink values too. The RGB compositor
runs on two stand-in documents whose channels hold the brightness of
cyan, magenta and yellow, then of black: everything allowed there works
channel by channel (checked by rendering random effect stacks with the
inks in different channels), so the result is each ink's own. Fill
layers enter the stand-ins as the compositor renders them in CMYK
(solid colours at the document's depth, gradients as its CMYK ramp), so
both routes give the same inks. Pattern paints, bevel textures, effect
modes that mix channels, Blend If and 32-bit documents still composite
in RGB and convert back through the profile.
Adds cmyk::render_display, the ink composite shown through the
document's profile, for a canvas to draw.
Invert, Posterize, and Levels and Curves recorded on the CMYK channels
now change a CMYK document's inks directly: each acts on the channel
brightness the document stores (the composite record on all four inks,
the black record on K only), mixed back by the layer's blend mode,
opacity and mask, then rounded to the document's levels as adjustment
layers are on the RGB compositor. Channels an adjustment leaves alone
keep their inks bit for bit. Clipped adjustments and layers clipped onto
an adjustment are covered. Adjustments that weigh the channels together
(Threshold, Hue/Saturation, Channel Mixer, ...) still composite in RGB
and convert back through the document profile.
Every blend mode that works channel by channel (Multiply, Screen, the
burns and dodges, the lights, Difference, Exclusion, Subtract, Divide,
Dissolve and the rest) now mixes CMYK layers on their ink values: the
mode acts on each ink's brightness, as the RGB compositor does on each
channel, so K-only black under a Multiply layer stays K-only. For the
special eight, Fill below 100% is part of the blend as on the RGB
compositor (#2552). Modes that mix channels (Hue, Saturation, Color,
Luminosity, Darker/Lighter Color) still composite in RGB and convert
back through the document profile.
Normal mixing onto nothing gives the source's ink exactly: a rounding
error there (1 -> 0.99999994) was magnified by modes that jump at full
ink, Reflect turning no ink into full K.
Stage 2 of mode-native CMYK compositing (#2220). Type, shape and smart
object layers are composited natively through their rendered pixels,
which are drawn in the document's model (a colour given in CMYK is drawn
with exactly those inks). Fill layers use the pixels they were rendered
to when they carry them (as PSDs supply them), and otherwise the
compositor's own CMYK rendering at the document's depth (solid colours
and gradient ramps, #2628).
Type layers mix their edges in the compositor's text gamma, on
brightness (1 - ink), so K-only type gains no cyan, magenta or yellow at
its edges; covered pixels, and channels both sides agree on, keep their
exact inks instead of taking the gamma round trip.
Still on the RGB compositor: pattern fills without rendered pixels, and
stroked shapes with visible clipped layers.
A CMYK document with more than one plain layer went through the RGB
compositor and was written to TIFF and JPEG as sRGB RGB. Flat export now
always writes a CMYK document as CMYK with its own profile:
- New compose::cmyk: a mode-native CMYK compositor for the stacks whose
blending is the same in every colour model (Normal pixel layers with
opacity, fill opacity, layer and vector masks; isolated and
pass-through groups; clipping groups). Pixels are mixed on their ink
values, so opaque pixels keep their exact inks (K-only black stays
K-only). Tiles render in parallel on native targets.
- Any other stack is composited in RGB and converted back through the
document's CMYK profile, as PSD export's merged image is, with a
warning that ink values can differ.
TIFF keeps transparency (CMYK + alpha); JPEG is composited over blank
paper (no ink) and written as CMYK; RGB-only formats still convert to
sRGB through the profile.
Fixes#2220.
every_tl_literal_is_translated cut each source file at its first `#[cfg(test)] mod`, so a small
test module early in a file hid every tl!("…") after it. panels.rs has one around line 540,
which left most of the toolbar options, the Layers panel and the Properties panel unchecked:
112 literals were never scanned.
The scan now removes each test module on its own (brace counting; a #[cfg(test)] on a single
item still doesn't count), with a unit test for the helper.
The strings it now finds are translated: 69 in Russian (most of the Layers panel and toolbar
tooltips), and the crop, lasso, zoom and fill hints in cs, de, es, fr, id, it, ja, ko, pl, pt-br,
uk, zh-hans and zh-hant. Translations reuse each catalog's existing terms; a native review is
welcome.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Comments and docs still said CI runs cargo test, that the craft-fonts tests run a second time in
the Linux job, and that CI's debuginfo matches the dev profile everywhere. development.md also
notes that test builds compile ui-egui unoptimized.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(vector): keep scaled live-line weight after editing endpoints (#3063)
* cargo fmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ui.pointer, ui.click/ui.move, ui.key and ui.screenshot read every value
with as_f64/as_bool/as_str and fell back to a default on any other type,
and an unknown button or event kind fell through to a left click or a
move. A typo such as "button":"ritgh" ran a different action and still
replied ok.
Each method now validates its whole request before acting, like ui.set:
unknown fields (top-level, under modifiers, or in an event), wrong JSON
types, unknown button/kind/tool values (the error lists the accepted
ones) and out-of-range pressure, tilt and rotation return an error that
names the parameter, and nothing is queued or applied. Null fields still
mean omitted, and valid calls behave as before.
Co-authored-by: Fabio Lussi <198260595+itrycodinganditsbad@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
* fix(io): preserve group fill opacity when exporting OpenRaster (#3048)
* cargo fmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Auto-Align Layers: register focus and exposure brackets by intensity when there is nothing to match
Feature matching fails outright on layers that nearly coincide (a focus bracket: sub-pixel shifts, up to a few percent of scale from focus breathing, much of every frame defocused). `photocraft_algo::direct` registers the target to the reference coarse-to-fine on a Gaussian pyramid of the luminance, the cost the mean-removed RMS of the warped difference over the pixels both cover, by a bounded Nelder-Mead search with a per-level schedule; the pose is a similarity about the centre, affine or projective per the projection, and resolution independent, so the search stops short of full resolution. `edit.autoAlignLayers` gets `registration`: auto (features, then intensity when nothing matches), features, intensity; layers register outward from the reference, each to the previous one aligned.
Closes#2064.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Intensity registration: reject a no-fit, search on coarsened planes
Review follow-up on #2065:
- `direct::cost` also returns the correlation of the reference with the
warped target over the overlap; `Registration.correlation` carries it.
Unlike the mean-removed RMS it is exposure independent, so it tells a
bracket (near 1) from unrelated pictures (near 0).
- `register_direct` fails with the existing "couldn't find enough matching
detail" error when a layer's best pose overlaps its neighbour by less than
a quarter of the plane or correlates below 0.5, instead of placing it at
whatever pose the search box ended at.
- The luminance planes are built at the search scale (`luma_alpha` with the
reduction factor, ≤ 2048 px across) and the warp of each registered layer
runs there too; the pose is resolution independent and its matrix at full
resolution places the layer. Nothing full-resolution is held.
- The reference index is checked once with `get`; no unclamped indexing.
- Tests: correlation at an exposure step, for unrelated textures and a flat
plane; the engine rejects unrelated layers and a mostly empty one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Auto-Blend Stack Images: fuse the merged layer per pyramid level by region energy, with halo control
The merged layer of Edit › Auto-Blend Layers › Stack Images was the per-pixel masks blended with a multiresolution spline, so a wrong pick in the mask reached every scale. `pyramid::fuse_stack` fuses the layers on the Laplacian pyramid instead: per coefficient the layer with the largest region energy of its luminance band wins (Adelson et al. 1984's multifocus composite with Wang & Chang 2011's rules), the residual follows local deviation + entropy, and with halo control the levels coarser than the guide are weighed by the guide's energy so a bright object's defocused glow stays out. `haloControl` (0..8, default 2) on `edit.autoBlendLayers`; the masks and the panorama method are unchanged.
Closes#2043.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
translate_vectors re-rendered a shape layer on every move. For a shape from a
PSD that replaced Photoshop's anti-aliasing with PhotoCraft's, so Artboards to
Files (which moves each board to the origin), the Move tool, nudges, layer
comps and moving artboards changed how imported shapes look.
A whole-pixel move now shifts the rendered pixels, through one shift_shape
helper shared with the Move tool's live preview (layer_multi_cmds::
shift_shown), which already did this. The render is cut at the canvas, so a
shape reaching past it still renders again, as does a fractional move; the
path moves either way, and fit_canvas still re-renders shapes when an
artboard move grows the canvas (#2389).
Measured on a Steam store asset template with #3218 (the same fix for type):
the "How to use" artboard has no pixel off by more than 2 levels from
Photoshop's own composite; before, both its shapes differed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Double-click a layer mask thumbnail to open its settings
Double-clicking a mask thumbnail in the Layers panel now opens that mask's settings in the Properties panel, matching Photoshop. When the Preferences ▸ Tools ▸ "Double Click Layer Mask Launches Select and Mask" option is on (the current default) a pixel mask still launches Select and Mask, exactly as before; with it off, double-clicking targets the mask and opens its Properties (Density/Feather). Vector masks now behave consistently too: double-clicking one targets it and opens a new Vector Mask Properties section.
* Fixed syntax issue from merge
* Fixed missing closed brace in ui tests
* Auto-Align Layers: register focus and exposure brackets by intensity when there is nothing to match
Feature matching fails outright on layers that nearly coincide (a focus bracket: sub-pixel shifts, up to a few percent of scale from focus breathing, much of every frame defocused). `photocraft_algo::direct` registers the target to the reference coarse-to-fine on a Gaussian pyramid of the luminance, the cost the mean-removed RMS of the warped difference over the pixels both cover, by a bounded Nelder-Mead search with a per-level schedule; the pose is a similarity about the centre, affine or projective per the projection, and resolution independent, so the search stops short of full resolution. `edit.autoAlignLayers` gets `registration`: auto (features, then intensity when nothing matches), features, intensity; layers register outward from the reference, each to the previous one aligned.
Closes#2064.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Intensity registration: reject a no-fit, search on coarsened planes
Review follow-up on #2065:
- `direct::cost` also returns the correlation of the reference with the
warped target over the overlap; `Registration.correlation` carries it.
Unlike the mean-removed RMS it is exposure independent, so it tells a
bracket (near 1) from unrelated pictures (near 0).
- `register_direct` fails with the existing "couldn't find enough matching
detail" error when a layer's best pose overlaps its neighbour by less than
a quarter of the plane or correlates below 0.5, instead of placing it at
whatever pose the search box ended at.
- The luminance planes are built at the search scale (`luma_alpha` with the
reduction factor, ≤ 2048 px across) and the warp of each registered layer
runs there too; the pose is resolution independent and its matrix at full
resolution places the layer. Nothing full-resolution is held.
- The reference index is checked once with `get`; no unclamped indexing.
- Tests: correlation at an exposure step, for unrelated textures and a flat
plane; the engine rejects unrelated layers and a mostly empty one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* fix(psd): Align global tagged blocks to four bytes
Use four-byte defaults for global blocks and streamed layer information.
Read global payloads without full copies while preserving block order,
explicit padding and the first layer candidate. Keep two-byte layer
alignment; test canonical padding and lossless PSD/PSB parsing.
* fix(psd): Preserve transparent composite colours and precision
* fix(psd): Check ZIP integrity and bound layer previews
* fix(io): Use document CMYK profiles for PSD fill pixels
Generated fill pixels used the default CMYK separation even when the PSD
embedded a different profile. Scope layer export to the document colour
space so cached pixels and the composite use the same profile.
Check native cached samples against an explicit ICC transform at 8 and
16 bits.
* io: refuse an empty RGB composite before splitting it into planes
chunks_exact(0) panics; an empty decoded composite now returns an error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Rulers: clip tick marks and labels outside the origin corner
* Rulers test: set ViewXform's new aspect field after merging main
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(type): use the next visual line at shared wrap boundaries
At soft-wrap and forced-break character offsets, resolve the caret's visual line from the last matching line rather than the preceding one. Make line-edge navigation share that choice and add regression tests for wrapped, forced and paragraph breaks.
* test(type): use actual break characters in caret boundary regressions
* fix(type): preserve the visual line when hit testing a shared wrap offset
Keep caret index preference on the following line, but use pointer geometry for click-hit line identity at an adjacent line's end.
* Update the caret round-trip test for wrap-boundary lines; cargo fmt
The existing round-trip helper expected the first line containing a
shared soft-wrap offset; the caret now reports the following line, where
it is drawn and where hit testing lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>