Set clipboard to image - pbcopy

How to set image as clipboard using pbcopy?

This does not work:

cat image.png | pbcopy 
+6
source share
3 answers

As indicated, this will not work with pbcopy , but you can write a small objective-c program for this: http://www.alecjacobson.com/weblog/?p=3816 . Then you can specify:

 cat image.png | impbcopy - 
+5
source

Updated Answer

In fact, you can put the JPEG image on the clipboard using Applescript, like this on the command line:

 osascript -e 'set the clipboard to (read (POSIX file "/Users/mark/Desktop/a.jpg") as JPEG picture)' 

Then you can check what is on the clipboard:

 osascript -e 'clipboard info' JPEG picture, 175960, «class 8BPS», 641904, GIF picture, 124637, «class jp2 », 102086, TIFF picture, 1481282, «class PNGf», 412940, «class BMP », 1477734, «class TPIC», 609835 

And also insert the image into the document with the usual -V.

Original answer

You can do this without having to compile any additional software and just use the tools provided in OS X. Basically, the clipboard cannot store binary files, so uuencode your binary image into plain ASCII data like this

 # Copy image to clipboard uuencode SomeFile.jpg - | pbcopy 

and uudecode on the return trip

 # Paste from clipboard to image file pbpaste | uudecode -o AnotherFile.jpg 
+4
source

From the documentation:

An input is placed in a card file as ASCII data, unless it starts with the Encapsulated PostScript (EPS) file header or the Rich Text Format (RTF) file header, in which case it is placed in cardboard as one of these data types.

It does not seem that image data is supported, so it will not work.

+3
source

Source: https://habr.com/ru/post/894151/


All Articles