* fix(engine): defined and imported patterns survive a restart (#9317)
The pattern library lived only in memory: patterns defined with Edit >
Define Pattern or imported from a .pat file were gone after a restart,
while their Patterns panel folders (saved with the preferences) still
named them. Photoshop keeps them.
The preset store now writes the user patterns (the library minus the
built-ins, in order) to patterns.pat, Photoshop's own pattern file
format, whenever their ids, names, sizes or order change, and loads
them when the store attaches. Like actions.json, a file that fails to
load is warned about and never overwritten. The web store accepts the
new record.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Patterns: persist same-id pixel replacements, retry a failed removal
CodeRabbit (discussion_r4369506324, r4369506326):
- an imported .pat whose id is already in the library replaces its
pixels, which the id/name/size key didn't show, so the old pixels came
back after a restart; PatternLibrary::pixels_rev is bumped on such a
replacement and is part of the key;
- a failed patterns.pat removal recorded the empty library as saved and
was never retried, so the deleted pattern came back; it now stays
pending, as a failed write does.
Tests: a_same_id_pattern_replacement_survives_a_restart,
a_failed_patterns_removal_is_retried.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Patterns: persist replaced built-ins and ASL replacements
CodeRabbit (discussion_r4369536978, r4369536981):
- a .pat import that replaced a built-in pattern by id was filtered out
as a built-in and never saved; only built-ins exactly as shipped
(is_pristine_builtin) are skipped now, and on load a saved built-in
takes the shipped one's place unless it changed before attachment;
- style.presets.importAsl replaced patterns by id without bumping
pixels_rev; both imports now go through PatternLibrary::upsert.
Tests: an_imported_builtin_replacement_survives_a_restart,
an_asl_pattern_replacement_bumps_pixels_rev.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* .pat: refuse names and counts the reader won't load, on write too
CodeRabbit (review 5641404908, outside-diff, two findings): now that the
preset store writes the user patterns, a file its own loader rejects or
truncates loses patterns at the next start.
- a name of 65,536+ UTF-16 units (with its NUL) was written although the
reader refuses it; write_pattern refuses it now;
- more than 100,000 patterns were written, and the reader kept the first
100,000 without a word; both now refuse counts over MAX_PAT_PATTERNS.
Tests: a_name_the_reader_refuses_is_refused_on_write,
more_patterns_than_a_pat_file_holds_are_refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Patterns: an early same-id import with other pixels is saved
CodeRabbit (review 5641454449, outside-diff, preset_store.rs:1191-1202):
a pattern imported before the store finished loading, with the id, name
and size of a saved one but other pixels, was appended (no pixels_rev
bump), won the merge, and then matched the loaded file's key, so it was
never written and a restart brought the old pixels back. The merge now
bumps pixels_rev when the copy it keeps differs from the saved one.
Test: an_early_same_id_import_wins_and_is_saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Crop and Straighten Photos processes only the selection (#9297)
Like Photoshop, File > Automate > Crop and Straighten Photos only searches
the selected area when there is a selection; before, it always split the
whole scan. The found photos are warped from the full canvas, so a photo
reaching past a tight marquee keeps its real pixels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address CodeRabbit review: mask unselected pixels before photo detection (#9297)
Pixels inside the selection's bounding box but outside the selection (holes,
gaps between regions) now read as background, so a photo there is not split
off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address CodeRabbit review: refuse a selection with no pixel at least half selected (#9297)
A faint feathered selection left every pixel unmasked, so photos outside
it could still be split off. The command now reports that no pixels are
more than 50% selected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
file.new takes "artboard": true: the document is one artboard over the
canvas, its background the chosen Background Contents, holding an empty
Layer 1 and no Background layer. The New Document dialog has an
Artboards box under Orientation that sets it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Image Rotation, rotated Crop, canvas flips and Image Size mapped a shape
layer's gradient fill through map_fill but never its stroke paint, so a
gradient stroke kept its old angle and offset while the fill turned.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Image Rotation › Arbitrary turns unlinked layer masks (#9201)
Free Transform's helper moves a pixel mask only when it is linked, so
rotating the whole image (and a turned crop) left unlinked masks of
non-Background layers in place. Warp them too, recursively into groups,
as every other canvas operation does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tests: the unlinked mask also turns the right way at 90° (#9201)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Package: never overwrite one link's copy with another, list a missing link once
Copies whose names collided were renamed to "<count>-<name>" once, without
checking that name too: links a/x.png, b/2-x.png and c/x.png packaged the
third over the second's copy, so two layers showed the same image. The name
now steps until no earlier copy has it, ignoring case as macOS and Windows
folders do. A missing link placed on several layers was listed once per layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPBRXWMhtDUsQDdZKmt9eZ
* Contributors: credit softwaregames1 by their GitHub profile name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPBRXWMhtDUsQDdZKmt9eZ
* Package: never overwrite a file already in Links
A second package into the same folder picked the same Links/<name> and
replaced the earlier copy. A name taken by a file already there is now
stepped like one taken by another link in this run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPBRXWMhtDUsQDdZKmt9eZ
* Apply suggestion from @coderabbitai[bot]
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
A newLayer clone copied back the union of every dab's box: one point far
off the canvas (e.g. [9e6, 9e6], accepted by the params) made it read a
region of petabytes and abort. The command and the stamp preview now copy
back and report damage only inside the canvas.
With an image on the clipboard (Paste is on by default), OK pastes first
and the strokes paint over and sample the paste, but the preview painted
the strokes on the unpasted layer and drew the paste on top. The preview
now pastes first too (shared paste_onto), repaints when the paste moves,
and the overlay is only drawn when no current preview shows the paste.
While the paste is dragged the baked preview is hidden so only one copy
follows the pointer; a plane drag freezes preview and paste until release.
Deleting the last plane now drops the stroke preview.
Co-authored-by: Valentin Klein <271991477+vangel76@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop keeps the pixels an earlier Delete Cropped Pixels off crop hid
only under a turned frame. A straight crop pulled back out over them fills
the whole area past the old canvas from the canvas, with Delete Cropped
Pixels off or on (checked: 64x48 green with a red left strip, crop to x=16
keeping pixels, then a Content-Aware crop to x=-24 w=72: all green). The
PR took the snapshot for straight crops too, so the hidden red came back.
The straight path is main's again; the turned path keeps the snapshot.
extending_crop_keeps_the_hidden_pixels becomes
extending_crop_fills_over_the_hidden_pixels (transparent and white
Background, Delete off and on); it fails with the straight snapshot back.
Co-authored-by: Michael Higgins <55243596+Higgs32584@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged with our fix-up d5139d177 (pr-1199-fixup), which merged main as of 8f09d122d.
Conflicts with main since then and with batch 8:
- photocraft-cli: main split the CLI into clap modules (#7071); the model wiring
(local_headless, configure_cli_models, batch's shared backend, droplet) is re-applied there.
- Cargo.lock regenerated: crates/ml pins ureq =3.4.2, so the app's ureq goes 3.5.0 -> 3.4.2.
- cutout_cmds: main's subject area (#8235) kept for the classical path beside the model path.
- file_cmds batch: main's per-input closure takes `s` later, so the backend and
integrations prefs are read before the closure instead of inside it.
- prefs_ui: model-choice filter with #4573's pref_choice_label; Integrations stays visible
(#4097) with the model choices only where models run; the translation-coverage test main
deleted (c3aa3f9e5) stays deleted; old section_fields test calls take PreferenceFieldOptions.
- Semantic clashes git did not flag: #4097's Integrations test literals in
apps/photocraft take ..Default::default() for the new model fields; main's and #4573's
section_fields test calls pass PreferenceFieldOptions.
- engine lib.rs, prefs.rs, smartselect tests, snapshot example, jobs_ui_tests, people.toml,
docs and i18n catalogs merged as unions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A UI Mixer Brush drag with a tip of 1025-5000 px was dropped on press: the live
preview refuses tips above 1024 px, and the canvas cleared the drag on any begin
error, though the status said the stroke would render on release (main painted
it). The drag is now kept when only the preview size refuses it
(`LiveMixer::defers_to_release`), and the release renders it; a stroke that
can't paint at all (a locked layer) is still refused on press.
Alt sampling tested `app.ui.tool`, so a held temporary tool (macOS Cmd = Move)
with Alt loaded paint; it now uses `active_tool()`, like `alt_eyedropper`.
The 65,536-sample and 250,000-dab caps also applied to the release replay and
the `paint.mixerBrush` command, so a long stroke (or Stroke Path with Simulate
Pressure, up to 200,000 samples) failed entirely; main had no cap. They now
bound the live preview only, which falls back to the replay.
Also: `cargo fmt` on the merged `LiveCommit` literal, and `as_chunks` in a test
for clippy's `chunks_exact_to_as_chunks`.
Co-authored-by: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- parse_fill took a present non-array "stops" / "opacityStops" / "midpoints"
as absent: {"gradient":{"stops":"red"}} silently became black to white. It is
an error now (CodeRabbit's finding); the hostile-values test also checks that a
rejected shape.create leaves the document and history alone.
- The swatches sent every gradient stop as sRGB RGBA, so in a CMYK or Lab
document ticking Reverse or changing the angle turned every stop into an RGB
colour (written back to PSD as RGBC). Stops now go out as stored Colors, which
shape.create / shape.edit accept, finite with alpha in 0..1.
- Options bar, strokeless shape selected, stroke gradient chosen: the width
field and the stroke type added a solid background-colour stroke. They take
the stroke gradient now, as the Fill checkbox and the next shape do.
Co-authored-by: Denis <179751626+deniskhud@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
panels.rs: the PR's snapshot rows next to main's History Brush source
and scroll-to-current; ui-parity.md: main's status line.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Main moved the shape options bar and paint swatch out of vector_ui.rs into
shape_options.rs and shape_paint_ui.rs (#5452). Carry the PR's gradient paint
over: PaintChange::Gradient, paint_param and the swatch's Gradient tab live in
shape_paint_ui.rs, the tool gradients and set_tool_paint in shape_options.rs,
and shape_gradient_ui.rs is its own module. Both sides' new tests are kept.
Co-authored-by: Denis <179751626+deniskhud@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roxmltree recurses once per element level, so a few thousand nested
tags overflow the thread stack, an abort no guard can catch. SVG checked
the nesting before parsing; the other five roxmltree callers now go
through photocraft_io::xml::parse, which applies the same check (512
levels) and, where a DTD is allowed (KRA), refuses an internal subset
whose entities could expand into nesting the check never sees.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The WebP branch built its image from meta(), which carries only the resolution and XMP, and
embed_metadata followed the XMP alone, so an EXIF-only photo lost its camera data in both lossy
and lossless modes. The filtered EXIF now goes onto the image and enables the metadata when
either it or the XMP is present. Regression: an EXIF-only photo exported as WebP (both modes)
keeps its EXIF with All and drops it for every other choice.
The Lustre `3DMESH` / `Mesh <inBits> <outBits>` header declares the cube edge
(2^inBits + 1) and the output code range (up to 2^outBits - 1); the parser
skipped every text line, so it inferred both from the data. That rejected a
3-squared cube whose three-value shaper row counted as a 28th node, and
divided 10-bit codes under a 12-bit declaration by 1023 instead of 4095.
Photoshop 27.11 accepts and renders both (measured by the reporters).
- prefs_ui `unimplemented_preferences_are_hidden_from_the_dialog` still asserted the
Integrations section is hidden, so test (ubuntu/windows) failed (FredApps' review).
It now asserts both rows are visible; scratchDisks stays hidden.
- `integrations()` parsed the whole preferences file strictly, so one wrong-typed value
anywhere (`{"interface":{"enableAnimations":"nope"},"integrations":{"allowAgentControl":false}}`)
reset Allow Agent Control to on while the dialog (lenient load, #6611) showed it off.
The section is now read on its own, and field by field when it doesn't read as a whole
(a list like `[false]` reads as a whole, as in the app); a test compares it with the
app's own load.
- Both rows are read only at launch: they say "Applies at next launch." like System Title Bar.
- Removed the stale "not by these yet" comment in HIDDEN_UNTIL_IMPLEMENTED.
Co-authored-by: Erica Franco <20589100+Erica4fr@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prefs.rs keeps main's demosaic default and the PR's write_xmp_sidecars, and
unhides the Camera Raw Defaults the PR makes live; the raw-open RawOpen built
without the dialog gains main's developed_with/demosaic; i18n and docs as
unions; docs/scorecard.md is regenerated in the fix-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clip each dab's source window to the dab's bounds plus one pixel for
bilinear sampling, so a large brush no longer allocates and copies the
whole tile-plus-halo window for every tile it overlaps. Pixels are
unchanged; a new test stamps with an oversized halo and compares.
Tolerance is a percentage of the channel range, and the default is now
0 (paint everywhere), as in Photoshop. At the old default of 50 a dab
was skipped unless the history state differed by half the channel
range on average, so most strokes painted nothing. The difference
average now leaves alpha out, so an unchanged alpha no longer dilutes
a colour change. A stroke whose every dab falls under the tolerance
returns with no damage and records no history step.
- Tolerance defaulted to 50 and averaged alpha into the difference, so an
ordinary edit (e.g. #c03030 -> #d04848) was never painted back, and a stroke
that wrote nothing still left an empty History step. Photoshop's default is
0; the difference is now the larger of the mean colour change and the
alpha change (the Eraser keeps colour and lowers alpha), and a stroke that
writes nothing is an error instead of an empty step.
- Each tile copied a source window of tile +- halo per dab: a leftward stroke
or a curl across x = 64 read empty pixels there (seam), and a size-1000 click
copied ~5e9 floats (11.9 s). The rotated read stays inside the dab, so it now
samples the source directly; bilinear reads at pixel centres, so an
unrotated dab copies the history pixel instead of a 2x2 blend.
- The brush used its own history lookup (state 0 by default): it now takes
the History Brush's source (history.setSource, snapshots, refusal after a
canvas size change).
- TOOL-213-20 is partial (8 of 10 styles, Area scales spacing); docs follow.
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preferences > Plug-ins derived the label from the key generatorEnabled
("Generator enabled"); Photoshop says "Enable Generator", which our own
Image Assets error already asks for. Override the label in humanize and
rename the catalog row in the 20 catalogs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop names a Lab document's Lightness channel Chnl.Lght and rejects
Chnl.Lmnc ("luminance") for Levels, Curves and Apply Image steps. Write
Lght, read Lght, and keep reading the Lmnc that earlier PhotoCraft wrote.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts with #5547 (Animated Zoom) resolved in wheel_nav.rs, canvas.rs and
panels.rs: the Navigator and canvas pass both Animated Zoom and
!animations_off; with Animation Effects off, the sideways part of an
animated wheel zoom pans by the frame's own events folded by their
modifiers (#4573's unsmoothed scroll) instead of the plain-event raw.x,
so Ctrl + wheel still pans sideways there. #4573's modifier test runs
with Animated Zoom off and on.
Translation catalogs keep main's strings plus the Art History Brush ones
(fr: main already has Area; hi: added the brush strings). docs/scorecard.md
regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The desktop build enables craft-ui's native-windows feature; the web build
keeps floating panels in the page. Every floating window gets its own OS
window (Ctrl/Cmd-drag, Float Panel, a drop that floats, restored layouts),
except the Studio themes' Properties card, which stays over the canvas.
Wayland keeps floating windows in the main window by craft-ui's rule.
- window.panel.window {panel, native?} runs as craft-ui's command; the web
refuses it, and so does the Studio card.
- Keys a panel window forwards run PhotoCraft's shortcuts in the same
frame, clipboard events included; keys held there count as held.
- While a dialog or other modal is open, the panel windows take no input.
- Files dropped on a panel window open as documents.
- Ctrl+click is a secondary click in panel windows on macOS too.
- The canvas paints no tool cursor while another of the app's windows has
the pointer.
An untagged document (a new one in the default working space, or a file
opened without a profile) is treated as sRGB (sGray for grayscale), but
Export As, Save As and Save for Web wrote no profile for it, so viewers
had to guess. Photoshop embeds sRGB IEC61966-2.1 for both a new and a
"Don't Color Manage" document when the profile is embedded.
A flat export to a format that carries profiles now tags an untagged
image with the profile assumed for its mode; the codec still leaves it
out when embedding is off, and formats without profiles are unchanged.
Save for Web does the same when Embed Color Profile is on.
Tests that relied on untagged exports carrying no profile (an EXIF
ColorSpace round trip, the Export As proxy-estimate premise, an Affinity
preview fixture, a WebP lossy check) now say so explicitly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Repin every craft-libs crate to 2869b8cc. The customized layout is a
craft_ui::docking::Workspace; window.panel.*, window.workspace.* and
ui.dock parse as DockCommand and apply through it. Workspaces saved
before the version field load with their hidden panels, dock-back
places and collapsed groups.
Type on a path keeps its own path, but nothing could edit it: the path
tools showed and edited the work path it was made from, so the text
stayed put. Its own path is now Photoshop's Type Path: with the type
layer selected, Direct Selection (and the anchor tools) show and edit
it, the path.* commands take it with "name": "layer", path.list names
it "<layer> Type Path", and the type is laid along it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Dragging every component with Path Selection moves the whole path
(`shape.edit` move), so a live rectangle or ellipse stays live instead of
losing its corner-radius widgets through `path.moveAnchors`.
- Esc and switching tools end a Pen draft with `pen_end`: a refused commit
(a locked layer) keeps the path as the Work Path instead of retrying
`shape.create` and the error on every frame. Return still keeps the draft
to commit again.
- The first component always draws as Combine: `path.setOperation` leaves
it alone (naming only it is refused), and the menu and + / - neither add
a History step for it nor show another operation.
- Only Path Selection, which shows the component selection, changes the
selected components; the Pen tools set the next path's operation.
Reconcile main 486afd82cc while preserving reviewed lifecycle, capture, IME and settings migrations. Include canonical dependency pins and the generated lockfile.
All nine CI stages passed: 11,580 passing test executions, zero failures and 91 ignored across 93 summaries. Native/browser acceptance and paired app performance remain open.
A pattern past the per-call budget is converted under one lock and shared while in use, with a one-time warning, and the desktop budget keeps every pattern a call uses (1 GiB). The web build caps a pattern's working copy at 128 MiB and a call at 256 MiB, and the pattern readers reserve their memory fallibly on every target. The legacy text restyle writes and compares BaselineShift, FontCaps, FontBaseline, UnderlinePosition, StrikethroughPosition and the ligatures per run, keeps an automatic leading's own value, and import reads the legacy AutoKern; a corpus test edits the size in psd-tools' text.psd and checks the rest of the legacy object is unchanged.
layer.new.artboardFromLayers takes width and height: the board gets
that size from the layers' top left (0 or none keeps their bounds), and
Layer > New > Artboard from Layers... opens a dialog with Name,
Background, Color, Width and Height instead of running at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>