I don't understand the operation of the "has (does not have) an image" operation. I selected and then copied a portion of a web page that has text and an image.
Upon testing the system clipboard condition, "has an image" returned false.
Testing "does not have an image" returned true.
Obviously, the clipboard does have an image. I tested this by pasting the text and image into a TextEdit file.
Could someone explain what I'm misunderstanding about the "has image" clipboard condition? Thanks.
has image is talking about whether there is an image flavor in the clipboard.
Every time you copy something, the clipboard is made up a a variety of different representations of the data copied, called “flavours”. For example, when you copy part of your web page, you will have multiple flavours:
plain text
UTF8 plain text
UTF16 plain text
rich text (RTF or RTFD or both)
custom web pasteboard flavour
and probably several more.
has image is referring to whether one of those flavors is an image (eg jpeg, png, etc) - that is, something you could paste into an image editor.
It is not referring to whether the rich text might have an image within it.
Thanks for the clarification. Is it possible to test the whole of a copied selection for the inclusion of an image, that is, anything beyond text?
Here is my goal: To save the clipboard contents into the simplest file format required. If an image is included, I might use an RFTD file, where if there is only text, I would use an RTF file.
If you happen to have DEVONthink installed (or maybe even DEVONnote but I'm not sure) you can do that "out of the box":
1 Select a portion of a webpage (that may or may not include images)
2 Press the shortcut to save the selected material as RTF(D) in the database (the shortcut is ⇧⌘) by default).
3 The selected material is automatically saved as RTFD if it contains images or RTF if it's only text.
Notice that I'm not advocating the purchase of DEVONthink for the OP usage case only; simply adding a piece of info in case it is useful to some forum fellows.