Place an image in the clipboard ?

hi.

I want to put a png image in the clipboard… right now, i’m doing it through preview but it’s less than ideal…

tell application "Finder"
    open theFile using alias "Macintosh HD:Applications:Preview.app:"
    
    tell application "System Events"
        keystroke "a" using command down
        keystroke "c" using command down
end tell
end tell

if i try something like:

set the clipboard to theFile

…then i don’t get the image in the clipboard…

how should i get the clipboard to contain the actual image?
thanks

hmm… actually, i think i might of found a way.

set the clipboard to (read ("Users/jeff/desktop/write_image.png") as TIFF picture)

.but i can’t put ’ as PNG picture’ . it has to be tiff ??

Hi,

easiest solution without any application and GUI scripting


set pngData to read file "MacHD:Path:To:Image.png" as «class PNGf»
set the clipboard to pngData

hey Stefan,

thank you…
that does it…

That is a great answer. Is there a place to find all of the file classes?

I copied a TIFF image to the clipboard (there is a TIFF picture type in AppleScript) and looked at the image representations with

the clipboard as record

Fantastic tip!