Skip to content

Open a layer capture's upscale as a new document at full size - #177

Merged
MehranMarxian merged 1 commit into
mainfrom
fix/upscale-layer-new-document
Nov 5, 2026
Merged

MehranMarxian merged 1 commit into
mainfrom
fix/upscale-layer-new-document

Conversation

@MehranMarxian

@MehranMarxian MehranMarxian commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes finding (2) from the 2026-11-05 G4 smoke run: "Upscale of a layer capture imports as a 4096 px smart object placed at 25%, so the layer is not visibly larger."

What the artist should get, and why

Proposal: upscaling a captured layer opens the result as a new document at its true size, for example 4096 × 4096 for a 1024 px layer with 4x-UltraSharp. Their own document is left untouched. Upscaling a captured canvas stays as it is: the document grows to meet the result.

Why not the other options:

  • Placing it in the same document (the old behaviour). Photoshop's default "Resize Image During Place" shrinks anything larger than the canvas to fit. A 4x result of a full-canvas layer comes back at 25% and looks exactly like the layer you started from. That's the finding. The smart object holds all 4096 px, but nothing on screen shows it.
  • The layer at true 4x size in the same document. A 4096 layer on a 1024 canvas shows about a sixteenth of itself and overflows on every side. Commit a3ea019 (August) already called that a bug. It's also what you get today with the preference switched off, so the old result depended on a preference most artists don't know about.
  • Growing the document, as a canvas capture does. That resamples every other layer in the file by a factor that means nothing to them. a3ea019 kept this for canvas captures deliberately, for that reason.
  • A new document. The artist sees exactly what they upscaled, at 100%, whichever way the preference is set. Nothing in their own file changes. If they want the result back in the original, they can drag the layer across.

What changed

  • src/photoshop/photoshopAdapter.ts: new importUpscaleResultAsNewDocument.
    • It creates a transparent RGB document with app.createDocument, at the result's exact size and the source document's resolution. The placed PNG is stamped with that same resolution, the Place results at the document's resolution (fixes imports into non-72 ppi documents) #156 rule.
    • It places the result, names the layer and positions it at 0,0.
    • It then checks that the placed layer covers the whole document. That proves Photoshop didn't shrink it, rather than assuming so.
    • If anything fails after the document exists, the new document is closed unsaved, and the error says "Your document was not changed."
    • The document is transparent so Photoshop's own Place removes its empty starting layer (the finding-3 behaviour, PR Record that the vanishing Layer 1 is Photoshop's own Place #176). The result is left as the only layer.
  • src/photoshop/upscaleResize.ts: two pure helpers. createUpscaleNewDocumentPlan gives the result's size, or null when it can't be read, in which case the import falls back to the floating layer as before. resolveUpscaleDocumentResolution gives the source ppi, or 72.
  • src/ui/App.ts: +30 lines, only in the layer-capture branch of importUpscaleResult.
    • The status reads "Opened as a new document: OpenLayer_Upscale_...".
    • The diagnostics say why: a layer capture has no canvas to resize, and your original document was not changed.
    • The canvas branch is byte-for-byte unchanged.
  • Docs: smoke step 2.3 now expects the new document, and the landing-page Upscale caption no longer says it "returns to the active document".

Not changed: the Import to Layers button label (panel markup is its own PR under CLAUDE.md), the agent bridge (it only triggers generation), and README / llms.txt, which say "Enlarge a layer 4x". That's still true.

What was verified

> npm run typecheck
> tsc --noEmit
(no errors)

> npm run lint
> eslint .
(no errors)

> npm test
 Test Files  142 passed (142)
      Tests  1407 passed (1407)

> npm run build
✓ built in 1.13s
Copied UXP assets to dist.

5 new tests in tests/photoshop/upscaleResize.test.ts cover the plan size, rounding, unusable sizes, and the resolution fallback.

In Photoshop 2025 (Windows 11), by Claude through computer-use, on this branch's dist/ (UXP Developer Tool › Reload), ComfyUI 0.44.0 on 8188, in new test documents only:

  1. Layer capture (the fix).
    • Setup: File › New, 1024 × 1024, 72 ppi, Transparent. Alt+Backspace, then Filter › Render › Clouds on Layer 1.
    • Steps: Upscale › Capture Active Layer ("Layer 1, 1024 x 1024") › Generate Upscale (upscale-basic, 4x-UltraSharp) › Import to Layers.
    • What it opened: a new document tab, OpenLayer_Upscale_20261105_1531 @ 25% (RGB/8). The status bar read 144.5 cm x 144.5 cm (72 ppi), which is 4096 px. History showed New, then Place Embedded Smart Object. There was one layer, the upscale: Photoshop's Place replaced the empty starting layer, as expected.
    • Proof it's at 100%: Ctrl+T put the Free Transform box exactly on the canvas corners, and the code's bounds check passed.
    • Panel: status "Opened as a new document: OpenLayer_Upscale_20261105_1531" (Ready). Diagnostics: "Opened ... as a new 4096 x 4096 document...".
    • The source document: Untitled-1 was still 36.12 cm (1024 px). Its History was only New, Fill Layer, Clouds, with no import step.
  2. Canvas capture (unchanged path).
    • Steps: same document, Capture Canvas ("Untitled-1, 1024 x 1024") › Generate › Import.
    • Result: Untitled-1 itself grew to 144.5 cm (4096 px), with History step "OpenLayer Upscale Document ..." and the upscale layer above Layer 1. The status read "Imported layer: ..." and "Document resized to ...", the same as before.

Both test documents were closed without saving.

What could NOT be verified

  • The failure path: closing the new document unsaved when the place or the bounds check fails. I couldn't make it fail on purpose without changing code.
  • Photoshop 2024 and macOS.
  • A source document at 240 ppi. The new document should be 240 ppi too.

Open questions

  1. Auto import: with "Import Automatically" on, every layer upscale now opens a new document. I think that's right, since it's what you asked for, but say if you'd rather it only happened on a manual import.

What Mehran should check in Photoshop

Test this branch: GitHub Desktop › Current Branch › fix/upscale-layer-new-document, then npm run build, then UXP Developer Tool › OpenLayer › Reload. ComfyUI has to be running.

  1. File › New, 1024 × 1024, Transparent › Create. Press Alt+Backspace to fill Layer 1, or paint anything on it.
  2. Home › Upscale, workflow upscale-basic, model 4x-UltraSharp › Capture Active Layer › Generate Upscale › Import to Layers.
  3. See: a new document tab named OpenLayer_Upscale_..., 4096 × 4096 (Image › Image Size), with one layer at 100%, and the status "Opened as a new document: ...". Untitled-1 is unchanged and still 1024 × 1024.
  4. Optional: repeat with Capture Canvas instead. See: Untitled-1 itself grows to 4096 × 4096, as before.

Smoke checklist blocks to re-check (docs/uxp-smoke-checklist.md)

  • Block 0: the panel starts (0.1 to 0.5)
  • Block 2, especially 2.3: Upscale of a captured layer opens a new full-size document
  • 2.3 with Capture Canvas: the document still grows, unchanged behaviour

🤖 Generated with Claude Code

Upscaling a captured layer imported the result as a floating layer in
the artist's document. Photoshop's default "Resize Image During Place"
shrinks anything larger than the canvas to fit, so a 4x result of a
1024 px layer came back at 25% and looked exactly like the layer it came
from (G4 smoke run 2026-11-05, finding 2). With the preference off it
overflows the canvas on every side instead, which a3ea019 already called
a bug.

Growing the document, as a canvas capture does, is wrong for a layer: it
would resample every other layer by a factor that means nothing to them.
So a layer capture's result now opens as a document of its own, made at
the result's exact size and the source document's resolution, with the
result placed in it at 100%. Nothing in the artist's document changes.
The place has nothing to shrink whichever way the preference is set, and
a bounds check proves it; on any failure the new document is closed
unsaved.

Canvas captures, and every other fallback, are unchanged. Smoke step 2.3
and the landing-page Upscale caption now describe what happens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MehranMarxian
MehranMarxian marked this pull request as ready for review November 5, 2026 12:04
@MehranMarxian
MehranMarxian merged commit aeebbbe into main Nov 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant