简体   繁体   English

有什么办法可以让 PIL 的 ImageGrab.grab() 保存小尺寸的照片?

[英]Is there any way to make PIL's ImageGrab.grab() save photos with a small size?

I'm using PIL with Python 3.8 to make screenshots of my screeen but the size of them is too large.我在 Python 3.8 中使用 PIL 来制作屏幕截图,但它们的大小太大了。 How can I reduce it?我怎样才能减少它?

您可以使用Image.resize()在保存之前缩小图像。

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 DocsPIL 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PIL的.crop返回图像0x0。 指定bbox的ImageGrab.grab也是如此 - PIL's .crop returns image 0x0. So does ImageGrab.grab with specified bbox 捕获屏幕有比PIL.ImageGrab.grab()更好的方法吗? - Is there any better way to capture the screen than PIL.ImageGrab.grab()? ImageGrab.grab() 的时序 function - Timing of ImageGrab.grab() function 屏幕截图(PIL)Win10上的ImageGrab.grab / BitBlt仅返回背景吗? - Screenshot (PIL)ImageGrab.grab / BitBlt on Win10 only return the Background? "ImageGrab.grab() 方法太慢" - ImageGrab.grab() method is too slow 如何使用ImageGrab.grab()。load()函数或任何其他函数获取像素更新? - How to use the ImageGrab.grab().load() function or any other function to get pixel updates? _tkinter.TclError:图像“...”不存在 _ImageGrab.grab() - _tkinter.TclError: image “…” doesn't exist _ ImageGrab.grab() ImageGrab.grab() 在第一个屏幕上运行代码时的第二个屏幕 - ImageGrab.grab() the second screen while running code on the first screen RGB是从ImageGrab获取的吗。grab()。load()是数组还是字符串 - Is RGB taken from ImageGrab.grab().load() is in array or string 使用 ImageGrab.grab() 时发生的奇怪事情 - Weird things happening when using ImageGrab.grab()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM