What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Selenium’s documented screenshot methods produce PNG data, not JPEG. To save a Selenium screenshot as a JPG, capture the PNG, open or decode it with an image library, convert it to a JPEG-compatible color mode, and encode it as JPEG. In Python, Pillow handles those steps; in Java, use Selenium’s screenshot bytes with Java’s ImageIO. Simply changing .png to .jpg does not convert the image.

Can Selenium save a screenshot directly as a JPG?

Not with Selenium’s documented Python screenshot methods. save_screenshot and get_screenshot_as_file write PNG files, while get_screenshot_as_png returns PNG bytes and get_screenshot_as_base64 returns base64-encoded screenshot data. Those are ways to capture or transport a PNG screenshot; none turns it into JPEG just because the output filename ends in .jpg.

The solution is to re-encode the captured pixels. Selenium takes the screenshot; an image library reads the PNG and writes a JPEG. The examples below use Pillow in Python and Java’s standard ImageIO API.

Save a Selenium screenshot as JPG with Python and Pillow

Install Pillow in the Python environment that runs your Selenium script:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
python -m pip install Pillow

After creating your WebDriver and navigating to the page you want to capture, use the following code. It reads the PNG directly from Selenium’s returned bytes, converts it to RGB, and writes a JPEG:

from io import BytesIO
from PIL import Image

# Assumes driver is an initialized Selenium WebDriver on the page to capture.
png_bytes = driver.get_screenshot_as_png()

with Image.open(BytesIO(png_bytes)) as image:
    image.convert("RGB").save("screenshot.jpg", "JPEG", quality=90)

Image.open accepts a file-like object, so there is no need to create an intermediate PNG file. convert("RGB") gives the JPEG encoder a supported color mode, and save explicitly selects JPEG. The value quality=90 is an example setting, not a Selenium requirement; select a quality that fits your image-size and visual-quality needs.

Use a temporary PNG file instead

If you want to inspect or retain Selenium’s original capture, write it to a PNG file first and convert that file:

Rank #2
Sale
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
from PIL import Image

# Assumes driver is an initialized Selenium WebDriver on the page to capture.
if not driver.save_screenshot("screenshot.png"):
    raise RuntimeError("Selenium could not save screenshot.png")

with Image.open("screenshot.png") as image:
    image.convert("RGB").save("screenshot.jpg", "JPEG", quality=90)

This approach leaves the PNG intact and produces a separate JPEG. Keeping both can be useful when the PNG is the lossless original and the JPG is a smaller or more convenient copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Preserve transparency by choosing a background

PNG can contain RGBA pixels with transparency. JPEG has no alpha channel, and Pillow’s documented JPEG writing modes are L, RGB, and CMYK. Converting a transparent image directly to RGB discards the alpha channel. If transparent pixels need a predictable appearance, composite them onto an explicit background before saving:

from io import BytesIO
from PIL import Image

# Assumes driver is an initialized Selenium WebDriver on the page to capture.
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", "JPEG", quality=90)

Here, fully transparent pixels become white and partially transparent pixels are blended against white. Replace "white" with another explicit background color if that better matches your use case. If transparency itself must survive, retain the PNG rather than converting it to JPEG.

Rank #3
Sale
Digital Camera, Latest FHD 1080P Digital Camera for Teens with SD Card Anti Shake Point and Shoot Cameras Portable 16X Zoom Compact Small Cameras for Kids Boys Girls Seniors with Wrist Strap
  • Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
  • Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
  • Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
  • WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
  • A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.

Save a Selenium screenshot as JPG with Java

Selenium Java’s TakesScreenshot.getScreenshotAs(OutputType) API can return screenshot data as bytes. ImageIO can read those PNG bytes; create an RGB image and write that image in JPEG format:

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

public class SaveScreenshotAsJpg {
    public static void save(WebDriver driver) throws IOException {
        byte[] png = ((TakesScreenshot) driver)
                .getScreenshotAs(OutputType.BYTES);
        BufferedImage image = ImageIO.read(new ByteArrayInputStream(png));
        if (image == null) {
            throw new IOException("Screenshot bytes could not be decoded as an image");
        }

        BufferedImage rgb = new BufferedImage(
                image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = rgb.createGraphics();
        try {
            graphics.drawImage(image, 0, 0, Color.WHITE, null);
        } finally {
            graphics.dispose();
        }

        if (!ImageIO.write(rgb, "jpg", new File("screenshot.jpg"))) {
            throw new IOException("No JPEG writer is available");
        }
    }
}

Call SaveScreenshotAsJpg.save(driver) after the driver has loaded the page. Drawing onto an RGB image with a white background makes the handling of any transparent pixels explicit. The ImageIO.write check avoids silently treating a missing JPEG writer as a successful save.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Selenium’s Java API also supports screenshot output as a file or base64, and OutputType provides file, bytes, and base64 forms plus PNG conversion hooks. These capture options do not themselves encode a JPEG; the separate image-encoding step is still needed.

Rank #4
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use

Choose the capture form that fits your workflow

Capture form What you start with Useful when Next step for JPG
Python bytes get_screenshot_as_png() returns PNG bytes You want to convert without writing an intermediate file Open from BytesIO, convert to RGB or composite, then save as JPEG
Python file save_screenshot("screenshot.png") writes PNG You want to keep or inspect the original PNG Open the PNG with Pillow and save a separate JPEG
Java bytes getScreenshotAs(OutputType.BYTES) provides screenshot bytes You want an in-memory conversion with ImageIO Read the bytes, draw into an RGB image, and write JPEG
Base64 Encoded screenshot data A workflow needs text-safe image transport Decode the base64 to PNG bytes first, then use the relevant image encoder

The scope of the image is a separate question from its format. In Java, Selenium documents best-effort screenshot behavior for non-W3C drivers: the returned image may cover the entire page, current window, visible frame, or display. Converting PNG to JPG changes encoding, not what the driver captured.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Quality, file size, and visual testing

  • Keep PNG for fidelity. PNG is lossless; JPEG is lossy. For visual regression tests or evidence where subtle pixel differences matter, compare or retain PNG rather than introducing JPEG compression artifacts.
  • Choose JPEG quality for the destination. The examples use quality=90 as a starting example. A higher setting generally preserves more image detail while potentially producing a larger file; evaluate the result for your particular screenshot rather than treating one number as universal.
  • Retain the original if you may edit later. Re-encoding to JPEG discards information, and saving a later version from the JPEG cannot restore it. Keep the initial PNG when lossless archival or editing is important.
  • Convert once, at the end. Capture PNG and encode one final JPEG rather than repeatedly opening and resaving JPEGs, which can compound lossy changes.
  • Plan for output paths and failures. Use an absolute destination path in scheduled jobs or services where the working directory may differ. Check Selenium’s boolean return for the file method, and handle image-read and file-write exceptions rather than assuming conversion succeeded.

Troubleshooting Selenium JPG conversion

Symptom Likely cause Fix
The file is named .jpg but an image viewer rejects it The PNG bytes were saved under a JPG extension without re-encoding Open the PNG data with Pillow or ImageIO, then save explicitly in JPEG format
Pillow reports an unsupported image mode when saving The source may be RGBA or palette mode, while JPEG writing supports L, RGB, and CMYK Convert to RGB before saving; if alpha matters visually, composite onto a chosen background first
Transparent areas look wrong or have an unexpected background JPEG cannot store alpha, and a direct RGB conversion does not preserve transparency Composite the RGBA source onto an explicit background color before JPEG encoding, or keep PNG
The Python conversion cannot open the image The byte stream may be empty or invalid, or the input path may not refer to the screenshot Confirm the driver is on the intended page, inspect that capture produced bytes or a PNG file, and pass the correct data or path to Image.open
The Java output file is missing The destination path may be unwritable, or image encoding may not have completed Use a writable absolute path, allow IOException to surface, and check the boolean returned by ImageIO.write
The screenshot does not show the whole page The capture extent depends on the driver and screenshot API behavior Verify what your driver captures before converting; JPG encoding cannot expand the captured region
Small visual differences appear in test comparisons JPEG compression introduces lossy artifacts Use PNG as the comparison artifact and create a JPG only for delivery or storage needs that call for JPEG

Or skip the browser setup

If you need a screenshot from a URL rather than a screenshot taken inside your Selenium session, ScreenshotNeo is a website screenshot API and MCP server. Its endpoint can return PNG, JPEG, WebP, or PDF; check the API documentation for the output-format options. This one-call cURL example saves the supplied WebP example output:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

It can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers reporting the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for free: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Does a JPG screenshot retain the original PNG’s transparency?

No. JPEG has no alpha channel. Keep the PNG if transparent pixels must remain transparent.

Does converting a Selenium screenshot to JPG make it a full-page screenshot?

No. Conversion changes the image encoding, not the capture scope; the screenshot extent depends on the Selenium API and driver.

Quick Recap

SaleBestseller No. 1
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$99.99
SaleBestseller No. 2
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$139.99
Bestseller No. 4
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$139.99

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.