Created
October 14, 2020 20:34
-
-
Save zno-man/f2ac90bbc9b13cfdf6aae6a48320c196 to your computer and use it in GitHub Desktop.
you can use this to save an image that has been copied to the clipboard (either using print screen or using windows key+shift+s) to a jpeg file just by double clicking,(i have tested it only on windows))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import ImageGrab | |
from win32 import win32clipboard | |
import time | |
def makeimg(): | |
name=time.time() | |
name=(str(name)) | |
im = ImageGrab.grabclipboard() | |
try: | |
im.save(name+'.jpeg','JPEG') | |
except: | |
win32clipboard.OpenClipboard() | |
data = win32clipboard.GetClipboardData() | |
print("this text was previously copied to the clipboard not an image :\n---------------------------------------------------------------------------------------- \n",data) | |
print("\n----------------------------------------------------------------------------------------") | |
win32clipboard.CloseClipboard() | |
else: | |
print("\n\n the image has been saved with the name {}.jpeg ".format(name)) | |
time.sleep(1) | |
makeimg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import ImageGrab | |
from win32 import win32clipboard | |
import time | |
def makeimg(): | |
name=time.time() | |
name=(str(name)) | |
im = ImageGrab.grabclipboard() | |
try: | |
im.save(name+'.jpeg','JPEG') | |
except: | |
win32clipboard.OpenClipboard() | |
data = win32clipboard.GetClipboardData() | |
print("this text was previously copied to the clipboard not an image :\n---------------------------------------------------------------------------------------- \n",data) | |
print("\n----------------------------------------------------------------------------------------") | |
win32clipboard.CloseClipboard() | |
else: | |
print("\n\n the image has been saved with the name {}.jpeg ".format(name)) | |
time.sleep(1) | |
makeimg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import ImageGrab | |
from win32 import win32clipboard | |
import time | |
def makeimg(): | |
name=time.time() | |
name=(str(name)) | |
im = ImageGrab.grabclipboard() | |
try: | |
im.save(name+'.jpeg','JPEG') | |
except: | |
win32clipboard.OpenClipboard() | |
data = win32clipboard.GetClipboardData() | |
print("this text was previously copied to the clipboard not an image :\n---------------------------------------------------------------------------------------- \n",data) | |
print("\n----------------------------------------------------------------------------------------") | |
win32clipboard.CloseClipboard() | |
else: | |
print("\n\n the image has been saved with the name {}.jpeg ".format(name)) | |
time.sleep(1) | |
makeimg() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment