What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Capture the screenshot as PNG, then decode it and re-encode the pixels as JPEG. Selenium’s screenshot APIs produce PNG data (a file, bytes, or base64), so changing .png to .jpg only changes the filename; it does not change the image format. In Python, Pillow performs the conversion:
from io import BytesIO
from PIL import Image
png_bytes = driver.get_screenshot_as_png()
with Image.open(BytesIO(png_bytes)) as image:
image.convert("RGB").save("screenshot.jpg", "JPEG", quality=90)
Why renaming a Selenium PNG does not create a JPG
A screenshot has both pixel data and an encoding format. Selenium’s documented Python methods write PNG files, return PNG bytes, or return base64-encoded PNG data. The filename extension does not control the bytes already produced by the browser. Renaming screenshot.png to screenshot.jpg leaves a PNG file with a misleading name; image viewers, upload validators, and libraries may reject it or identify it as PNG.
A real conversion has four stages:
- Capture the current browser view with Selenium.
- Decode the PNG bytes or file.
- Convert the pixel mode to one JPEG supports.
- Encode and save a new file using JPEG.
JPEG is lossy and has no alpha channel. Keep the original PNG when you need pixel-perfect evidence, later editing, or visual-regression comparisons.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsPython: convert screenshot bytes directly to JPG
Install the conversion library
Install Pillow in the same Python environment as your test code:
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
python -m pip install selenium pillow
The following example avoids a temporary PNG. Selenium returns PNG bytes, Pillow opens those bytes through an in-memory stream, and save explicitly selects JPEG:
from io import BytesIO
from PIL import Image
# driver is an already-created Selenium WebDriver
png_bytes = driver.get_screenshot_as_png()
with Image.open(BytesIO(png_bytes)) as image:
rgb = image.convert("RGB")
rgb.save("screenshot.jpg", format="JPEG", quality=90)
quality=90 is a practical starting point, not a Selenium requirement. Lower values usually produce smaller files with more visible artifacts; higher values preserve more detail while increasing size. The conversion does not change the captured width or height.
Use a file-based workflow
If your test artifacts already require a PNG, save it first and convert that file:
Recommended Free Tools
from selenium import webdriver
from PIL import Image
# Configure the driver for your browser and environment.
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
driver.save_screenshot("screenshot.png")
with Image.open("screenshot.png") as image:
image.convert("RGB").save("screenshot.jpg", "JPEG", quality=90)
finally:
driver.quit()
save_screenshot returns whether the driver accepted the save operation; production code should also check that the expected file exists and is readable before converting it.
Convert base64 screenshot data
When a test framework transports screenshots as text, decode Selenium’s base64 result before passing it to Pillow:
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
import base64
from io import BytesIO
from PIL import Image
encoded = driver.get_screenshot_as_base64()
png_bytes = base64.b64decode(encoded)
with Image.open(BytesIO(png_bytes)) as image:
image.convert("RGB").save("screenshot.jpg", "JPEG", quality=90)
Handle transparency and image modes correctly
PNG can contain RGBA pixels (red, green, blue, and alpha) or palette data. Pillow’s JPEG writer accepts grayscale (L), RGB, and CMYK images, so converting to RGB before writing is the safe default. A direct RGB conversion discards transparency. If transparent pixels should appear on a particular background, composite them explicitly:
from io import BytesIO
from PIL import Image
png_bytes = driver.get_screenshot_as_png()
with Image.open(BytesIO(png_bytes)) as source:
rgba = source.convert("RGBA")
background = Image.new("RGB", rgba.size, "white")
background.paste(rgba, mask=rgba.getchannel("A"))
background.save("screenshot.jpg", format="JPEG", quality=90)
Use another background color by replacing "white" with a color name or an RGB tuple such as (240, 240, 240). JPEG cannot preserve the alpha channel itself.
Choose the capture representation that fits your pipeline
| Representation | Use it when | Conversion path |
|---|---|---|
| PNG file | You want a human-inspectable intermediate artifact or need to retain lossless evidence. | Image.open("screenshot.png"), then convert and save. |
| PNG bytes | You want to avoid disk I/O or pass the image to another service. | Image.open(BytesIO(driver.get_screenshot_as_png())). |
| Base64 text | Your test runner or message format transports text. | Base64-decode to bytes, then open with Pillow. |
For large test suites, the bytes approach avoids writing and rereading a temporary PNG. JPEG encoding still consumes CPU, so choose a quality level that meets your artifact-size requirement rather than blindly maximizing it.
Java: capture PNG bytes and encode with ImageIO
Selenium Java exposes screenshots through TakesScreenshot.getScreenshotAs(OutputType). The capture API supplies PNG data; Java’s standard ImageIO performs the separate JPEG encoding.
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
// driver is an already-created WebDriver.
byte[] png = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
BufferedImage source = ImageIO.read(new ByteArrayInputStream(png));
if (source == null) {
throw new IllegalStateException("The driver did not return a readable PNG");
}
BufferedImage rgb = new BufferedImage(
source.getWidth(), source.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = rgb.createGraphics();
graphics.drawImage(source, 0, 0, Color.WHITE, null);
graphics.dispose();
if (!ImageIO.write(rgb, "jpg", new File("screenshot.jpg"))) {
throw new IllegalStateException("No JPEG writer is available");
}
The white paint supplies a background when the source has transparency. For a non-transparent screenshot, drawing directly into the RGB image is sufficient. Selenium’s Java documentation describes best-effort screenshot scope for non-W3C drivers: depending on the driver, the result can be the entire page, the current window, a visible frame, or a display. JPEG conversion changes encoding only; it does not expand or shrink that capture scope.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Java file and base64 variants
OutputType.FILE can provide a temporary screenshot file that you read with ImageIO.read. OutputType.BASE64 can be decoded with Java’s base64 decoder and passed to the same ImageIO.read step. OutputType.BYTES is usually the simplest route when the final destination is a JPG file or an upload stream.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Quality, paths, and artifact handling
Pick quality deliberately
Quality 90 is a useful example for screenshots containing text and interface detail. Test several values against your storage limit if file size matters. JPEG artifacts are especially noticeable around small text, one-pixel borders, and high-contrast icons. For visual regression, compare PNG files instead; lossy JPEG blocks can create differences unrelated to your UI.
Use predictable paths
Relative paths are resolved from the process working directory, which can differ between a local shell and continuous integration. Build an absolute artifact path, create its parent directory, and report the final path in test logs. If a conversion fails, preserve the source PNG so the original capture is available for diagnosis.
Write safely in parallel tests
Give each test or browser session a unique filename. Otherwise parallel workers can overwrite one another. A temporary output followed by an atomic rename is useful when another process watches the artifact directory, because readers never observe a half-written JPG.
Troubleshooting Selenium-to-JPEG conversion
“The JPG” is reported as a PNG
The extension was probably changed without re-encoding. Open the source with Pillow or ImageIO and write a new file using the JPEG encoder.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Pillow raises an error about the image mode
The source may be RGBA or palette-based. Call convert("RGB"). If transparency must remain visually meaningful, composite the RGBA image onto an explicit background first.
The output is blank or the page is incomplete
Conversion cannot repair a bad capture. Make sure navigation and the page state you need have completed before calling the screenshot method. For an element or full-page workflow, verify that your selected driver and Selenium API actually support that capture scope; the Java API’s scope is driver-dependent.
The file cannot be opened after saving
Check the destination directory, permissions, available disk space, and the return value of the file-writing operation. In Python, catch OSError around save; in Java, check both ImageIO.read and the boolean returned by ImageIO.write.
Files are unexpectedly large
Lower the JPEG quality gradually, or retain PNG only for cases that need lossless detail. Resizing before encoding can reduce dimensions, but it changes the screenshot itself and should be a deliberate test decision.
Images differ between operating systems
JPEG encoding is only one source of variation. Browser rendering, device scale, fonts, viewport dimensions, and driver behavior can also change the captured pixels. Standardize those inputs when screenshots are test artifacts.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Or skip the browser setup
If you need a hosted screenshot rather than a Selenium-controlled browser, ScreenshotNeo is the first service to try: it returns clean shots, bills only clean shots, and its paid entry plan is $5 for 3,000 shots.
ScreenshotNeo accepts a URL and returns PNG, JPEG, WebP, or PDF. Before capture, it accepts the cookie or consent banner like a visitor and removes 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.
One GET request is enough:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all request options and response details. The same call in Python is:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const buffer = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', buffer));
Options for automation and AI workflows
ScreenshotNeo has 63 options, including full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or any viewport, retina scale, PDF paper settings and page ranges, HTML/CSS-to-image, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, ad and tracker blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed links for public <img> tags, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes every feature:
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | No card required |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing gives two months free. You can sign up for 1,000 free screenshots a month with no card.
Implementation checklist
- Capture with Selenium’s PNG-producing API.
- Decode the file, bytes, or base64 data instead of renaming the extension.
- Convert RGBA or palette images to RGB; composite transparency when the background matters.
- Choose JPEG quality based on the reader, storage, and artifact requirements.
- Keep PNG for lossless evidence and visual-regression comparisons.
- Use unique, absolute artifact paths and verify writes in automation.
- Use ScreenshotNeo when a hosted, cleaned capture or an AI-agent workflow is more appropriate than maintaining browser setup.
Frequently Asked Questions
Does converting to JPEG change the browser viewport that Selenium captured?
No. JPEG conversion only changes how the captured pixels are encoded; the viewport, window, or page extent is determined by the Selenium driver and capture call.
Should a test upload PNG or JPG as its canonical screenshot?
Use PNG as the canonical artifact when exact pixels matter. Generate a JPG derivative for systems that require JPEG or for smaller, lossy previews.
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.

