2

Figma allows to me copy elements to clipboard as images: PNG or SVG. I can then paste these directly into some programs. For example, I can paste it as an image into Pages or Google Docs.

Problem

But many programs need an image to be a file before I can use it, usually by drag-and-drop.

What I've tried

Figma allows for exporting image files, but it's a lot more steps. I can also create a new file from clipboard image with Preview, but that's again more steps, and it doesn't work for SVGs.

What I want

I'd like to be able to select my desktop or a folder, paste the image, and result in a new file. Is there a way to do it?

2
  • 2
    Pasting an image into Pages is pasting the bytes, which gets translated to how the app uses the data in an open document. Finder is a fuel viewer, so it’s expecting you to paste an actual file information. It then operates on the file instead of the data. Commented Nov 14, 2022 at 19:10
  • I don't have Figma, but I generally find opening Preview.app and then creating a new document works. Commented Mar 1 at 17:07

1 Answer 1

3

Make an Automator service with a keyboard shortcut

  1. Install PNG Paste
  2. Paste code to make an Automator workflow
  3. Add keyboard shortcuts to trigger the workflow

Using V in Finder.app will paste image data from the clipboard (if it's there) as a file, or else paste normally.

1. Install pngpaste

Run this Homebrew command in Terminal to install the pngpaste command line utility.

  1. brew install pngpaste

2. Make a Service with Automator

Make a type of Workflow called a Service, which will appear in Finder menu → Finder → Services. It tries to paste an image as a file, or else performs a normal paste.

  1. Open Automator.app

  2. New File → Quick Action → Choose

  3. Set parameters

    Filename: Paste Clipboard Image as File
    Workflow receives no input in Finder

  4. Add Run AppleScript action, and replace its code with

on run {input, parameters}
    
    set cbInfoAsString to (clipboard info) as string
    
    if cbInfoAsString contains "«class furl»" then
        
        tell application "System Events" to ¬
            keystroke "v" using control down
        
    else
        set formattedDate to do shell script ¬
            "date -j '+%Y-%m-%d at %H.%M.%S'"
        
        if cbInfoAsString contains "TIFF picture" then  
            tell application "Finder" to set thePath to ¬
                (insertion location as alias) & ¬
                formattedDate & ".png" as string
            do shell script "/opt/homebrew/bin/pngpaste " & ¬
                the quoted form of the POSIX path of thePath
            
        else if paragraph 1 of (the clipboard as text) contains "<svg" then
            
            tell application "Finder" to set thePath to ¬
                (insertion location as alias) & ¬
                formattedDate & ".svg" as string
            do shell script "pbpaste -Prefer txt> " & ¬
                the quoted form of the POSIX path of thePath
            
        end if
    end if
end run

3. Add keyboard shortcuts

Remap Finder's normal Paste command to a secondary keyboard shortcut V. Then assign the primary keyboard shortcut V to our new script.

  1. System Settings → Keyboard → Keyboard Shortcuts → App Shortcuts → Add (+)

    Field Value
    Application Finder.app
    Menu Title Paste
    Keyboard Shortcut V
  2. System Settings → Keyboard → Keyboard Shortcuts → Services → General

    Under Paste Clipboard Image as File, double-click None to replace it with keyboard shortcut V

4. Test

  1. Copy an image as image data. Use V to paste it into Finder. An image file should appear. Test for both PNG and SVG (e.g., in Figma's Copy as PNG and Copy as SVG).

  2. Copy a non-image file. Use V to paste it into Finder. The file should appear like it would before you followed this guide.

If "Finder.app" wants access to "System Events.app", that's OK.

"Finder.app" wants access to "System Events.app"

Same for permitting the service to send keystrokes; give accessibility permissions to Finder.app to make this error go away.

"Paste Clipboard Image as File is not allowed to send keystrokes."

Credit

The process has been adapted from @Landon. The code has been slightly modified from @user3439894's answer to Detect whether clipboard item is image data using AppleScript. This script does not have error-checking, so it may create unpredictable side effects when not used as prescribed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .