Skip to content

Adding the feature 'New from Clipboard' - #201

Open
tgrvrs wants to merge 1 commit into
robbietilton:mainfrom
tgrvrs:new-image-from-clipboard
Open

tgrvrs wants to merge 1 commit into
robbietilton:mainfrom
tgrvrs:new-image-from-clipboard

Conversation

@tgrvrs

@tgrvrs tgrvrs commented Sep 30, 2026

Copy link
Copy Markdown

Adds File > New from Clipboard (⇧⌘V), as in Preview. It opens the image on the clipboard as a new project that is exactly the size of the image, in one step. Until now you had to go through New Canvas (which already fills in the clipboard image's size), click Create, and then paste, which made two undo steps. It works for pixels copied inside Compositor and for
images copied in other apps.

What's added

  • A New from Clipboard item in the File menu, below New Canvas, with ⇧⌘V as its default shortcut. The shortcut can be changed in the keyboard shortcuts settings like the others.
  • ProjectWorkspace.newFromClipboard(): creates a new tab with a document the size of the copied image, holding the image as its only layer. Creating the document and adding the layer are one undo step, named "New from Clipboard".
    • Pixels copied in any open project come first, the same way Paste chooses. Otherwise it uses an image from another app, converted to the working sRGB format.
    • An empty first tab is reused, as when an image is dropped onto the app.
    • An image bigger than the document limits shows the usual import error (ImageImportError.tooLarge). If the clipboard holds no image, the app beeps.
  • EditorSession.pasteboardImage(): the code that reads an image from another app, moved out of Paste so both commands use it.
  • A line in the README feature list.

Not covered: a whole layer copied with ⌘C and no selection. That puts only the layer's ID on the pasteboard, not an image, so New from Clipboard beeps. Supporting it would mean rendering the copied layer (or folder, or adjustment layer) into an image first. I've left that out to keep this change small, but I'm happy to add it if you want it.

How to use

  1. Copy an image: a selection in Compositor (⌘C), a screenshot to the clipboard (⌃⇧⌘4), or an image from a browser or another app.
  2. Choose File > New from Clipboard or press ⇧⌘V.
  3. A new project opens with the image as "Layer 1", at the image's exact size. ⌘Z undoes it.

Tests

Two new tests in SelectionClipboardTests:

  • newFromClipboardOpensATabTheSizeOfTheCopiedPixels: copies a 30×20 selection and checks the new tab's size, its single layer (name, position, size, pixels), the undo name, and that the source project is left unchanged.
  • newFromClipboardTakesAnImageFromAnotherApp: puts a PNG on the pasteboard and checks that the empty first tab is reused at 12×7. It then checks that text on the clipboard returns false and opens no tab.

🤖 Generated with Claude Code

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