Clipboard Image With More Formats Using Rotate Image Action

I ran into an issue with the Screenshot to Clipboard Interactively Macro related to this Set System Clipboard to File Reference action:
image
The action does put the image on the clipboard, but pasting into some apps (Messages, Unclutter...) resulted in a generic thumbnail rather than the actual image. The issue is related to clipboard/pasteboard/format/sharing issues that are above my pay grade, but I stumbled across a little trick that bailed me out so I thought I would share.

Adding a Rotate Image action (set to 0 degrees so it doesn't actually rotate), puts a duplicate of the image on the clipboard with additional formats which can be interpreted by other apps.
image
I also added an action to delete the past clipboard to get rid of the original so I wouldn't have duplicates.
image
Will anyone need this? No idea, but I was happy to stumble across it.

1 Like

the image losing format sounds like a bug,
tried reaching Peter?

No, I didn't reach out to @peternlewis originally, because I didn't know if it was by design that the Set System Clipboard to File Reference writes only the one representation to the pasteboard. Also, I don't really know what I'm talking about, so there's that. But maybe he wants to weigh in.

Hey Evan,

The issue here is that you're using the Set Clipboard to File Reference action.

image

It does exactly what it's supposed to in placing a file reference on the clipboard:

{
   {
      «class furl», 
      49
   }
}

This is quite clearly a File-URL and just that. Some applications will accept that as a proxy for the image itself and will allow you to paste the image.

Some apps are looking for an actual image flavor on the clipboard.

What you need to use is the Read a File action with the Clipboard parameter.

image

{
   {
      TIFF picture, 
      52098
   }, 
   {
      «class 8BPS», 
      118154
   }, 
   {
      GIF picture, 
      15507
   }, 
   {
      «class jp2 », 
      21699
   }, 
   {
      JPEG picture, 
      33432
   }, 
   {
      «class PNGf», 
      38301
   }, 
   {
      «class BMP », 
      393078
   }, 
   {
      «class TPIC», 
      62130
   }
}

I'm using AppleScript and Script Debugger's Pretty Print feature to display:

clipboard info

Even though my image (zest.png) is a PNG file, you'll note that a number of other image flavors have been placed on the clipboard.

An alternative method of doing this task would be to copy your screenshot to the clipboard

screencapture -ic

And the write the file yourself using the Write to a File action.

-Chris

1 Like

Yes that makes perfect sense, the "reference."

FWIW, the Set Clipboard to Image action behaves the same way, which I would not have expected based on your «class furl» explanation

Excellent solution!

screencapture -ic

I've used this approach, but it won't work for this particular macro because, as far as I can tell, there is no way to use the -c switch and get the "interactive" feature of the clipboard.

Thanks for your help, Chris. The explanations you include with your solutions always help me learn.

Hey Evan,

Ha! I was looking for that and missed it entirely...

Even after all these years I still don't know everything about Keyboard Maestro.

:sunglasses:

The set clipboard to image action does the right thing on my system (macOS 10.12.6 with Keyboard Maestro 9.2):

{
   {
      TIFF picture, 
      54656
   }, 
   {
      «class 8BPS», 
      122424
   }, 
   {
      GIF picture, 
      20865
   }, 
   {
      «class jp2 », 
      26539
   }, 
   {
      JPEG picture, 
      37993
   }, 
   {
      «class PNGf», 
      42569
   }, 
   {
      «class BMP », 
      393078
   }, 
   {
      «class TPIC», 
      62130
   }
}

I don't understand.

On my system screencapture -ic explicitly brings up the interactive screenshot selection UI and copies to the clipboard instead of a file.

You bet.

Glad to hear it!

-Chris

I'm on Big Sur, so that may explain the differences?

  • I get only «class furl» 47 using set clipboard to image action.
  • I do not get the interactive screenshoot UI with screencapture -ic - that would be much simpler than the macro I made!

Well, that’s frustrating...

Type:

man screencapture

Into the Terminal.app and look at the syntax.

Maybe Apple has changed it.

Type 'q' to quit the man page viewer in the Terminal.

-Chris

Yes, Set Clipboard to Image, given a file reference, will set the clipboard to the file reference, since that is the highest possible quality.

I'm not sure why its not doing that for Chris.