What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use Pillow’s ImageGrab.grab() to capture the current desktop, then save the returned image. Call ImageGrab.grab(bbox=(left, top, right, bottom)) when you need only a rectangle. The exact pixels, color mode, monitor coverage, and even whether capture works depend on your operating system, display server, Pillow version, and desktop permissions.
This guide covers full-screen, regional, multi-monitor, and single-window captures, Retina sizing, Linux display requirements, verification, troubleshooting, and an API alternative for capturing web pages rather than your local desktop.
Install Pillow and verify the environment
Install or upgrade Pillow in the Python environment that will run the capture:
python -m pip install --upgrade Pillow
Check the installed version and confirm that Python imports the package:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
python -c "import PIL; print(PIL.__version__)"
Pillow’s platform-support page distinguishes continuously tested operating systems from platforms reported to work, so a listed operating system does not guarantee that every local display session can be captured. See the official platform-support documentation for that distinction.
Capture the entire primary screen
Import ImageGrab, call grab() without arguments, and save the returned PIL image:
from PIL import ImageGrab
screenshot = ImageGrab.grab()
screenshot.save("screenshot.png")
By default, Pillow copies the entire screen available through the platform capture path. The result is a normal PIL image, so you can inspect it, convert it, resize it, or save it in formats supported by your Pillow installation.
Choose an output format
The filename extension usually selects the encoder. PNG is lossless and appropriate for text or interface screenshots; JPEG is smaller but introduces compression artifacts; WebP can provide a smaller file when your Pillow build includes WebP support.
Free tools Windows power users keep installed
One-click scans. No signup required.
from PIL import ImageGrab
image = ImageGrab.grab()
image.save("desktop.png")
image.save("desktop.jpg", quality=90)
image.save("desktop.webp", quality=85)
Use a format whose encoder is available in your installation. If saving fails, try PNG first and inspect the exception message.
Capture a rectangular region with bbox
Pass a four-value bounding box in screen coordinates: (left, top, right, bottom). The right and bottom values mark the far edge of the region.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
from PIL import ImageGrab
region = ImageGrab.grab(bbox=(100, 100, 800, 600))
region.save("region.png")
This example requests the rectangle from x=100 through x=800 and y=100 through y=600 in the desktop coordinate system. Coordinates are not automatically relative to the active window. On a multi-monitor desktop, they follow the virtual screen layout, which can include negative values.
Validate the captured geometry
Before processing a region, print its dimensions and mode:
from PIL import ImageGrab
image = ImageGrab.grab(bbox=(100, 100, 800, 600))
print("size:", image.size)
print("mode:", image.mode)
image.save("region.png")
A malformed or out-of-place box can produce an unexpected size or an empty-looking result. Measure coordinates against the same display arrangement and scaling used by the process taking the screenshot.
Understand image modes and Retina dimensions
Windows and Linux modes
The API documentation states that captures are generally RGB on platforms other than macOS. RGB images have three color channels and can be saved directly as PNG or JPEG.
macOS mode and Retina scale
macOS captures are RGBA, which adds an alpha channel. Code that requires RGB can convert explicitly:
from PIL import ImageGrab
image = ImageGrab.grab()
rgb = image.convert("RGB")
rgb.save("mac-screen.jpg", quality=90)
On Retina displays, the physical capture can be twice the logical width and height. Pillow 12.3.0 added the keyword-only scale_down=True option to request 1× sizing. Use it only when the installed Pillow version supports it:
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
from PIL import ImageGrab
image = ImageGrab.grab(scale_down=True)
print(image.size)
image.save("retina-1x.png")
Without that option, retain the higher-resolution image when you need pixel-level detail. Check image.size rather than assuming that logical display dimensions equal the returned pixel dimensions. The option and Retina behavior are documented in the ImageGrab reference and the Pillow 12.3.0 release notes.
Capture every monitor on Windows
Windows supports all_screens=True to request the complete virtual desktop instead of only the primary display:
from PIL import ImageGrab
all_monitors = ImageGrab.grab(all_screens=True)
print(all_monitors.size)
all_monitors.save("all-monitors.png")
When monitors are arranged to the left or above the primary display, the virtual desktop’s top-left coordinate can be negative. Supply such coordinates in bbox when cropping across the full layout. The Windows-only include_layered_windows option can include layered windows when supported by your installed Pillow version.
Capture one window on supported systems
The window argument captures a single window by native identifier: an HWND on Windows or a CGWindowID on macOS. Pillow added Windows support in 11.2.1 and macOS support in 12.1.0. Older installations may reject the argument.
from PIL import ImageGrab
# Replace WINDOW_ID with an HWND (Windows) or CGWindowID (macOS).
image = ImageGrab.grab(window=WINDOW_ID)
image.save("window.png")
You must obtain the native identifier through operating-system APIs or another window-management tool; ImageGrab does not discover a window from its title. If the argument is unavailable, upgrade Pillow or capture a coordinate rectangle instead.
Linux display requirements and fallbacks
On Linux, ImageGrab.grab() uses an X11 display path when xdisplay is None. If the default X11 capture does not return an image, Pillow may use an installed gnome-screenshot, grim, or spectacle utility. Pass xdisplay="" to disable that fallback behavior:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
from PIL import ImageGrab
image = ImageGrab.grab(xdisplay="")
image.save("linux-screen.png")
Use the default first. Disable fallbacks only when you deliberately want to prevent external utility calls. Pillow documents checking XCB support with:
from PIL import features
print(features.check_feature(feature="xcb"))
Clipboard image capture on Linux, where used, requires wl-paste or xclip. A headless shell, an unavailable X11/Wayland session, or a process without access to the graphical display can prevent capture regardless of Python code.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesA reusable capture script with options
This command-line example supports a full screen or a rectangle, prints the result, and converts macOS RGBA output only when JPEG is requested:
import argparse
from pathlib import Path
from PIL import ImageGrab
parser = argparse.ArgumentParser()
parser.add_argument("output", nargs="?", default="screenshot.png")
parser.add_argument("--bbox", nargs=4, type=int, metavar=("LEFT", "TOP", "RIGHT", "BOTTOM"))
parser.add_argument("--all-screens", action="store_true")
parser.add_argument("--scale-down", action="store_true")
args = parser.parse_args()
kwargs = {"all_screens": args.all_screens}
if args.bbox:
kwargs["bbox"] = tuple(args.bbox)
if args.scale_down:
kwargs["scale_down"] = True
image = ImageGrab.grab(**kwargs)
output = Path(args.output)
if output.suffix.lower() in {".jpg", ".jpeg"} and image.mode not in {"RGB", "L"}:
image = image.convert("RGB")
image.save(output)
print(f"saved {output} ({image.size[0]}x{image.size[1]}, {image.mode})")
Examples:
python capture.py desktop.png
python capture.py panel.png --bbox 100 100 800 600
python capture.py monitors.png --all-screens
python capture.py retina.png --scale-down
Do not pass --scale-down to a Pillow version that predates 12.3.0. For a script that must run across mixed versions, detect support by checking the installed version or handle the resulting TypeError and retry without that keyword.
Troubleshoot blank, failed, or incorrect screenshots
Import or installation errors
- “No module named PIL”: run
python -m pip install Pillowwith the same Python executable used to launch the script. - Unexpected keyword argument: your Pillow version may not support
scale_downorwindowon that operating system. CheckPIL.__version__and upgrade when appropriate.
Black, blank, or missing output
- Confirm the process has an interactive graphical session rather than a headless service account.
- On Linux, verify X11/XCB availability and install the documented fallback utility when your desktop requires one.
- On macOS, check the operating system’s screen-recording permission for the application running Python.
- Print
image.sizeandimage.modebefore downstream processing to distinguish a capture problem from a display or conversion problem.
Wrong area or monitor
- Recheck that
bboxis ordered left, top, right, bottom, not x, y, width, height. - Use the virtual-desktop coordinate system. Negative coordinates are valid on Windows when a monitor lies left or above the primary display.
- Account for display scaling and Retina physical pixels by measuring the returned image rather than assuming logical dimensions.
Permission and security boundaries
Operating-system permissions, remote-desktop policies, compositor behavior, and protected-content rules can block or alter a screenshot. Pillow’s documentation describes API behavior, not a universal permission prompt or guarantee for every desktop environment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and safe processing
Capturing a full multi-monitor desktop creates more pixels than capturing a small bbox, so crop at capture time when you know the target area. Save to a local writable path and close or overwrite files according to your workflow. For repeated captures, avoid unnecessary format conversions; PNG preserves interface text but can be larger, while JPEG encoding trades size for artifacts.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
For reliable automation, log the timestamp, requested box, returned size, mode, output path, and exception text. Treat a successful Python call as evidence that an image object was returned, not proof that every window or protected surface was visible. Verify the file exists and has nonzero size before uploading it.
Or skip the browser setup
ImageGrab captures the desktop where Python is running. If what you need is a clean screenshot of a public web page, ScreenshotNeo makes one GET request and returns PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie and consent banners before removing more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.
ScreenshotNeo also provides an MCP server for Claude, Cursor, and other MCP clients, with take_screenshot, get_page_info, and capture_pdf tools. Every plan includes its features, including full-page lazy-image loading, CSS-selector element capture, device presets, custom JavaScript and CSS, waits, request blocking, headers and cookies, geolocation, resizing, caching, signed links, asynchronous webhooks, bulk capture, and usage reporting.
Using the API:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for options and response headers. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWhen ImageGrab is the right tool
- Use ImageGrab for the desktop, a local application window, or a coordinate region on the machine running Python.
- Use
all_screens=Truewhen Windows virtual-desktop coverage is required. - Use ScreenshotNeo when the target is a web URL, you need repeatable server-side rendering, or an AI agent should request captures through MCP.
Frequently Asked Questions
Does ImageGrab capture a browser page without the browser being visible?
No. ImageGrab captures the desktop or supported native window visible to the operating-system capture path. It does not render a URL independently of a local graphical session.
Can I use a four-value box as x, y, width, height?
No. Pillow expects (left, top, right, bottom). Calculate the right and bottom edges before calling grab().
Why is a macOS screenshot larger than my display resolution?
Retina capture can return physical pixels at 2× logical dimensions. Pillow 12.3.0 and later can request 1× output with scale_down=True.
Is ImageGrab available in a server or Docker container?
Only when the process has access to a usable graphical display and the required platform capture path. A headless container normally needs a separately configured display server.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

