Set clipboard to image - pbcopy

Viewed 5402

How do you set an image as the clipboard with pbcopy?

This doesn't work:

cat image.png | pbcopy
5 Answers

one alternative that works for both images and animated gif is:

osascript -e 'tell app "Finder" to set the clipboard to ( POSIX file "<PATH_TO_IMAGE>" )'

The actual (or final) answer to how to copy a PNG image into the macos' clipboard was hidden in the comments to the Mark's answer. As it is not (that) obvious from Mark's answer and it took me a while to find it I will leave it as an answer here:

osascript -e 'set the clipboard to (read (POSIX file "/Users/mark/Desktop/a.png") as  {«class PNGf»})'
Related