Skip to content Skip to sidebar Skip to footer

Copy An Image To Macos Clipboard Using Python

I want to copy an image (PIL image) to clipboard on Mac OS I tried dozens of different ways to do that. Most of python clipboard modules like pyclip or clipboard doesn't support im

Solution 1:

This little piece of ugliness works and loads "image.jpg" onto the clipboard...

#!/usr/bin/env python3

import subprocess

subprocess.run(["osascript", "-e", 'set the clipboard to (read (POSIX file "image.jpg") as JPEG picture)'])

Post a Comment for "Copy An Image To Macos Clipboard Using Python"