How in Python to upload a picture to the clipboard from url. Download it and upload to the clipboard in Windows 10.
Here it is:
import requests
from PIL import Image
from io import BytesIO
import win32clipboard
response = requests.get(url="https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Emergency_hospital_during_Influenza_epidemic%2C_Camp_Funston%2C_Kansas_-_NCP_1603.jpg/220px-Emergency_hospital_during_Influenza_epidemic%2C_Camp_Funston%2C_Kansas_-_NCP_1603.jpg")
image = Image.open(BytesIO(response.content)) # convert it to a "Image" Object
tempIO = BytesIO()
image.save(tempIO,'BMP') # save it to a IO object as BMP format
# write it to clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardData(win32clipboard.CF_DIB,tempIO.getvalue()[14:])
win32clipboard.CloseClipboard()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.