.save() is an attribute of image. You need to save like:
from PIL import ImageGrab, Image
m1 = ImageGrab.grabclipboard()
m1.save('test_image.png')
Answer from Stephen Rauch on Stack OverflowPillow Documentation
pillow.readthedocs.io › en › stable › reference › ImageGrab.html
ImageGrab module - Pillow (PIL Fork) 12.2.0 documentation
The ImageGrab module can be used to copy the contents of the screen or the clipboard to a PIL image memory.
GitHub
github.com › python-pillow › Pillow › issues › 648
ImageGrab.grab().save(file) throws IOError: screen grab failed · Issue #648 · python-pillow/Pillow
May 8, 2014 - File "C:\Python27\Lib\site-packages\commonlibs\logger.py", line 149, in grabScreen self.saveImage(file) File "C:\Python27\Lib\site-packages\commonlibs\logger.py", line 56, in self.saveImage = lambda file: ImageGrab.grab().save(file) File "C:\Python27\Lib\site-packages\PIL\ImageGrab.py", line 31, in grab size, data = grabber() IOError: screen grab failed ·
Author kmelnikov
TutorialsPoint
tutorialspoint.com › python_pillow › python_pillow_imagegrab_grab_function.htm
Python Pillow - ImageGrab.grab()Function
The ImageGrab module in the Pillow library provides functionality to capture the contents of the screen or the clipboard and store it as a PIL image in memory. The ImageGrab.grab() function is used to capture a screen snapshot.
Stack Overflow
stackoverflow.com › questions › tagged › imagegrab
Newest 'imagegrab' Questions - Stack Overflow
When I use the code normally before compiling it works perfectly but when compiling to .exe with cxfreeze or pyinstaller and running the software freezes import pyscreenshot as ImageGrab import ... ... I'm developing a bot for telegram that keeps open, the first time it saves the file it works normally, but the second time it overwrites the previously written file.
HotExamples
python.hotexamples.com › examples › PIL › ImageGrab › grabclipboard › python-imagegrab-grabclipboard-method-examples.html
Python ImageGrab.grabclipboard Examples, PIL.ImageGrab.grabclipboard Python Examples - HotExamples
These are the top rated real world Python examples of PIL.ImageGrab.grabclipboard extracted from open source projects. You can rate examples to help us improve the quality of examples. ... def save_img(): pic = ImageGrab.grabclipboard() filename = time.strftime("%Y%m%d-%H%M%S", time.localtime()) filename = filename+".png" print(filename) pic.save(filename) return filename
Top answer 1 of 2
1
try
import win32api, win32con, ImageGrab
win32api.keybd_event(win32con.VK_SNAPSHOT, 1)
im = ImageGrab.grabclipboard()
im.save("screenshot.jpg", "JPEG")
I think the key here is importing the winapi too.
Source
2 of 2
1
Ok, I found the answer, apparently
scrgrb = ImageGrab.grabclipboard()
Should actually be
scrgrb = ImageGrab.grab()
I found this on the top answer here Python windows 7 screenshot without PIL
The documentation on the PIL website doesn't show this change -.-
Bitbucket
hhsprings.bitbucket.io › docs › programming › examples › python › PIL › ImageGrab.html
ImageGrab Module (macOS and Windows only) — Pillow (PIL) examples
Update Pillow. img = ImageGrab.grabclipboard() if img and not isinstance(img, (list, )): #img.show() img.save("capturedd.png" % self._count) self._count += 1 elif key == keyboard.Key.alt_l or key == keyboard.Key.alt_r: self._alt_pressed = False elif key == keyboard.Key.esc: # Stop listener return False if __name__ == '__main__': kc = KC() with keyboard.Listener( on_press=kc.on_press, on_release=kc.on_release) as listener: listener.join() Using PyAV, you can directly encode these images to movie like this: #! /bin/env python # # NOTE: # Please stop running other capturing applications like 'DropBox' before # running this demonstration.
GitHub
github.com › PySimpleGUI › PySimpleGUI › blob › master › DemoPrograms › Demo_Save_Window_As_Image.py
PySimpleGUI/DemoPrograms/Demo_Save_Window_As_Image.py at master · PySimpleGUI/PySimpleGUI
:param filename: The filename to save to. The extension of the filename determines the format (jpg, png, gif, ?) """ widget = element.Widget · box = (widget.winfo_rootx(), widget.winfo_rooty(), widget.winfo_rootx() + widget.winfo_width(), widget.winfo_rooty() + widget.winfo_height()) grab = ImageGrab.grab(bbox=box) grab.save(filename) ·
Author PySimpleGUI
DevDungeon
devdungeon.com › content › grab-image-clipboard-python-pillow
Grab Image from Clipboard in Python with Pillow | DevDungeon
October 28, 2018 - You can get the bytes by simply using the same save() method used to write files. Instead of passing it a filename though, pass it an in-memory binary stream, BytesIO object. For more information on working with bytes and binary data, check out my tutorial, Working with Binary Data in Python. from PIL import ImageGrab import io img = ImageGrab.grabclipboard() # Store the bytes in a byte stream img_bytes = io.BytesIO() img.save(img_bytes, format='PNG') print(img_bytes.getvalue())
GitHub
github.com › python-pillow › Pillow › issues › 6126
ImageGrab.grab colors switched · Issue #6126 · python-pillow/Pillow
March 12, 2022 - What did you do? screenshot2 = ImageGrab.grab(all_screens=True) What did you expect to happen? That the ImageGrab saves the Image with the right colors^^ What actually happened? The colors are swit...
Author BigDvsRL
Top answer 1 of 2
1
You can use Image.resize() to shrink the image prior to saving.
2 of 2
1
from PIL import Image
im = Image.open("hopper.jpg")
# Provide the target width and height of the image
(width, height) = (im.width // 2, im.height // 2)
im_resized = im.resize((width, height))
source PIL Docs
TutorialsPoint
tutorialspoint.com › python_pillow › python_pillow_imagegrab_grabclipboard_function.htm
Python Pillow - ImageGrab.grabclipboard()Function
from PIL import ImageGrab # Take a snapshot of the clipboard image clipboard_image = ImageGrab.grabclipboard() # Check for the clipboard object is an image or not if isinstance(clipboard_image, Image.Image): # Display or save the clipboard image clipboard_image.show() else: print("The clipboard does not contain image data.")
Videohelp
videohelp.com › software › screenshots › imagegrab
ImageGrab 7.0.4 Download Free - VideoHelp
May 2, 2023 - ImageGrab is a powerful and user-friendly software that opens all kinds of video files and allows to extract images either in the format bmp, or in jpeg with a quality adjustable.