Filter Clipboard: Remove Images From the Clipboard

Is there any way to remove images from the clipboard without changing the style of the text?

The filter remove style is able to remove the images (seems to change the whole clipboard to plain text). But, I don't want that because I want to keep the text styles. I just want to filter the images from the clipboard, and past the rest.

Is there any ways of removing/deleting images from the clipboard?

Hey @Desalegn,

Doubtful.

What app(s) are you working in?

-Chris

@ccstone: thank you for the reply.

I am just copying and pasting a lot of text from https://glosbe.com/.

I am learning a new language. I want to study the example sentences from Glosbe. But, there are some annoying images that come with the text. I was thinking if there is any way of filtering out those images.

If these images are ads, then you might try one of the ad-blocker extensions for your browser.

Write the clipboard to an RTF file, and then read the read the file back to the clipboard. RTF supports styles, but not images (RTFD supports styles and images) so this should generally retain (most of) the styles while dropping the images.

Keyboard Maestro Actions.kmactions (925 B)

6 Likes

That is a smart solution. Thank you.

Is this still the best way to remove images from a clipboard while retaining the text styles?

It's the best I know.

1 Like

Ok, thanks Peter!

Hey Chris,

Ask on the Script Debugger Forum.

It might be possible with AppleScriptObjC to skip writing the file.

-ccs

Will do, thanks Chris.

Thanks for linking to Shane's script for me. I came back here to do this just now and realized you had beat me to it haha.

For anybody else who stumbles across this thread, the link @ccstone linked to is to a question I posted on the Script Debugger forum, where an AppleScript was provided that accomplishes removing images from the clipboard without removing text styles.

In my limited testing, it works fine, albeit slightly slower than the RTF method that @peternlewis provided. Approximately 0.4 seconds slower. Very minimal, but if speed is your game, then the RTF method might be better suited for you.

On my old Mid-2012 i7 MacBook Air:

Time ⠀⠀⠀ Run Mechanism
0.23 Seconds │ Peter's Macro to run and Paste
0.57 seconds │ FastScripts to run AppleScriptObjC and Paste
0.89 seconds │ Keyboard Maestro to run AppleScriptObjC (text script) and Paste
0.97 seconds │ Keyboard Maestro to run AppleScriptObjC (compiled script) and Paste

Peter's macro is definitely the speed winner.

Since Keyboard Maestro runs AppleScript using osascript it's a little slower than other AppleScript-runner mechanisms.

The thing that shocks me here is that the text script is faster than the compiled script. I've never seen that before...

I'll have to test this more when Keyboard Maestro 10 comes out.

-Chris

1 Like

That is….odd to say the least. First time I’ve seen a text script run faster than a compiled script as well.

Which should be any day now, right? :wink::sweat_smile: