I’m attempting to follow this advice on SO and it isn’t working: macos - Set clipboard to image - pbcopy - Stack Overflow
osascript -e 'set the clipboard to (read (POSIX file "/Users/mark/Desktop/a.jpg") as JPEG picture)'
I’m testing that line above in Terminal. I’m changing the path to a jpg on my own system. But it isn’t working. The clipboard is coming in as PNG.
Ultimately, what I’m trying to do is write an Alfred workflow to take a screenshot as a jpeg, save it to a screenshot folder as a jpg, and then automatically copy it as a jpeg to my clipboard for pasting in another location, such as a document, Scrivener, Obsidian, forum, etc.
Even if I change the MacOS screenshot format to jpg, builtin screenshots still come in as PNG to the clipboard!
defaults write com.apple.screencapture type jpg
My example script in Alfred (everything works except the clipboard is still PNG):
CURDATE=`date '+%F_%I-%M-%S'`
IMGPATH="/Users/chris/screenshots/screenshot_"$CURDATE".jpg"
screencapture -i -t jpeg -x -r "$IMGPATH"
# This is still copying/pasting as a PNG...
osascript -e 'set the clipboard to (read (POSIX file "'"$IMGPATH"'") as JPEG picture)'
- I wonder why this isn’t working as expected. Monterey regression? Is there a subtle typo/bug on my part?
- Anyone know any alternatives I can try?