
PNG to JPG and Back: 9 Ways to Convert Without Wrecking the Image
Convert PNG to JPG or JPG to PNG on any platform. Why transparency turns black, why JPG to PNG never restores quality, and which direction is right for photos, logos and screenshots.
PNG and JPG solve different problems, which is why converting between them goes wrong in two specific, predictable ways.
PNG to JPG loses transparency, and the transparent parts usually turn black rather than white. JPG to PNG restores nothing — it takes an already-degraded image and stores it in a container three to eight times larger.
Both conversions are the right answer sometimes. This guide covers nine ways to do them and, more usefully, how to know which direction you actually need.
Which Direction Do You Need?
| Your image | Correct format | Why |
|---|---|---|
| Photograph | JPG | Smooth gradients compress well, artifacts hide in detail |
| Screenshot | PNG | Text edges stay sharp, flat colour compresses better |
| Logo or icon | PNG | Transparency, and hard edges must not blur |
| Diagram or chart | PNG | Same as above |
| Scanned document | PNG | JPEG artifacts around letters lower OCR accuracy |
| Photo with transparency | PNG, or WebP | JPEG cannot store an alpha channel |
| Photo for a web page | WebP or AVIF | Both beat JPG by 25–50% |
Notice that “photograph” is the only row where JPG wins.
The size difference is not a constant — it flips completely depending on the content, which is why a single rule like “PNG is bigger” is wrong. Two measurements on real files:
The Right Format Depends Entirely on the Content
A rendered document page at 300 DPI, and a 1200×630 illustration. Same encoders, same settings.
On a page of text, PNG is 2.6× smaller than JPEG — large flat white areas compress almost perfectly, while JPEG spends bits on artifacts around every letter. On the illustration, the ranking reverses and JPEG is 5.8× smaller.
One caveat worth stating plainly: for a screenshot of a modern web page — anti-aliased text over gradients — JPEG usually still comes out smaller than PNG. It just does so by damaging exactly the edges you care about. The reason to choose PNG there is fidelity, not size.
Pick Your Method First
| # | Method | Platform | Batch? | Install? |
|---|---|---|---|---|
| 1 | Browser converter | Any | Yes | No |
| 2 | macOS Preview and Finder | macOS | Yes | No |
| 3 | sips |
macOS | Yes | No |
| 4 | Windows Paint and Photos | Windows | No | No |
| 5 | PowerToys Image Resizer | Windows | Yes | Yes |
| 6 | ImageMagick | Any | Yes | Yes |
| 7 | Python and Pillow | Any | Yes | Yes |
| 8 | GIMP Script-Fu | Any | Yes | Yes |
| 9 | Online converters | Any | Yes | No |
The Black Background Problem
This is the single most reported issue, and it has a one-line fix.
PNG stores an alpha channel: every pixel carries a transparency value. JPEG has no such channel. When a converter meets a transparent pixel it has to invent a colour, and unless told otherwise many tools use the alpha value itself, which for fully transparent pixels is zero — black.
So a logo with a transparent background becomes a logo on a black rectangle.
# Wrong: transparency becomes black
magick logo.png logo.jpg
# Right: say what the background should be
magick logo.png -background white -alpha remove -alpha off logo.jpg
# On a brand colour
magick logo.png -background "#0F172A" -alpha remove -alpha off logo.jpg
-alpha remove composites the image over the background colour. -alpha off then discards the now-unused channel. Both are needed; using only the first leaves some tools still writing an alpha channel that JPEG cannot hold.
The same applies everywhere. In Photoshop, flatten the image before exporting. In Preview, the export dialog offers no control, so it uses white. In Pillow, you must composite manually — see method 7.
Semi-transparent pixels matter too. A logo with a soft drop shadow has pixels that are 30% opaque. Flattening onto white gives a light grey shadow; flattening onto black gives a dark one. Choose the background that matches where the image will actually sit, or the edges will look wrong.
JPG to PNG Restores Nothing
The other half of the confusion. People convert a JPG to PNG expecting “lossless quality”, and get a much larger file containing exactly the same degraded pixels.
JPEG’s compression is destructive and one-way. It discards high-frequency detail and quantises colour in 8×8 blocks. Once saved, that information does not exist in the file. PNG stores whatever you give it perfectly — including the blocking artifacts, the ringing around edges, and the colour banding.
| File | Size | Actual detail |
|---|---|---|
photo.jpg, quality 80 |
240 KB | Degraded |
photo.png converted from it |
2.1 MB | Identically degraded |
Convert JPG to PNG only for these reasons:
- You are about to edit it and want no further loss during your working passes
- A tool or platform demands PNG — some print services, some upload forms, some game engines
- You need to add transparency by cutting out a background afterwards
- The image is actually a screenshot that someone wrongly saved as JPG, and you want to stop the damage compounding
Otherwise, keep the JPG.
1. A Browser Converter
The quickest route, and the files never leave your machine.
- PNG to JPG
- JPG to PNG
- PNG to WebP — usually the better choice for a web page
- JPG to WebP
Everything runs in the browser through WebAssembly, so you can drop in a batch without an upload wait.
2. macOS Preview and Finder
Finder, for a batch, since macOS Monterey:
- Select the files
- Right-click → Quick Actions → Convert Image
- Choose JPEG or PNG, pick a size, tick Preserve Metadata
Preview, one file: File → Export, choose the format, and for JPEG set the quality slider. Preview flattens transparency onto white with no option to change it.
3. sips
Built into macOS, no install, scriptable.
# PNG to JPG
sips -s format jpeg -s formatOptions 92 image.png --out image.jpg
# JPG to PNG
sips -s format png image.jpg --out image.png
# A whole folder
mkdir -p jpg
for f in *.png; do
sips -s format jpeg -s formatOptions 92 "$f" --out "jpg/${f%.png}.jpg"
done
sips flattens transparency onto white. If you need a different background colour, use ImageMagick.
4. Windows Paint and Photos
Paint: open the file, File → Save as, choose JPEG picture or PNG picture. Paint flattens transparency onto white and strips all metadata.
Photos: open, ⋯ → Save as, pick the format.
Neither offers a quality setting for JPEG, and neither does batches.
5. PowerToys Image Resizer
The batch answer on Windows without touching a command line.
- Install Microsoft PowerToys
- Select any number of images in File Explorer
- Right-click → Resize with Image Resizer
- Open Settings in the dialog to set the output format and JPEG quality
- Choose Actual size if you only want the format change
It writes copies rather than overwriting, and handles hundreds of files.
6. ImageMagick
The most control, and the only method here that lets you choose the flattening colour.
# PNG to JPG, one file
magick photo.png -quality 92 photo.jpg
# A folder
magick mogrify -format jpg -quality 92 *.png
# With explicit flattening, which you almost always want
magick mogrify -format jpg -quality 92 -background white -alpha remove -alpha off *.png
# JPG to PNG
magick mogrify -format png *.jpg
# JPG to PNG with maximum compression effort
magick photo.jpg -define png:compression-level=9 photo.png
# Convert and resize together
magick mogrify -format jpg -quality 88 -resize 2000x2000\> -background white -alpha remove -alpha off *.png
Strip the Metadata, or Keep It Deliberately
# Remove EXIF, GPS and colour profiles
magick mogrify -format jpg -quality 92 -strip *.png
# Keep the colour profile but drop everything else
magick photo.png -quality 92 -strip -profile sRGB.icc photo.jpg
Stripping saves a few kilobytes and removes location data. It also removes the colour profile, which can shift colours on wide-gamut images. Our colour spaces guide explains when that matters.
7. Python and Pillow
# pip install pillow
from PIL import Image
# PNG to JPG, flattening transparency onto white
image = Image.open("logo.png")
if image.mode in ("RGBA", "LA", "P"):
rgba = image.convert("RGBA")
background = Image.new("RGB", rgba.size, (255, 255, 255))
background.paste(rgba, mask=rgba.split()[-1])
image = background
else:
image = image.convert("RGB")
image.save("logo.jpg", "JPEG", quality=92, optimize=True, progressive=True)
# JPG to PNG
Image.open("photo.jpg").save("photo.png", optimize=True)
The mask=rgba.split()[-1] argument is what makes semi-transparent pixels blend correctly. Without it, pasting produces hard edges where the soft shadow should be.
progressive=True is worth setting on any JPEG destined for the web. It renders in increasingly sharp passes rather than top to bottom, which looks faster on a slow connection and often produces a slightly smaller file.
8. GIMP Script-Fu
Free, cross-platform, and it handles batches from the command line without you writing a plugin.
gimp -i -b '(let* ((files (cadr (file-glob "*.png" 1))))
(while (not (null? files))
(let* ((filename (car files))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))))
(gimp-image-flatten image)
(let ((drawable (car (gimp-image-get-active-drawable image))))
(file-jpeg-save RUN-NONINTERACTIVE image drawable
(string-append filename ".jpg") "" 0.92 0 1 1 "" 0 1 0 0))
(gimp-image-delete image))
(setq files (cdr files))))' -b '(gimp-quit 0)'
gimp-image-flatten composites onto the current background colour, which defaults to white. This is worth knowing about mostly because GIMP is already installed on many machines where ImageMagick is not.
9. Online Converters
Fine for images that are already public. Wrong for client artwork, unreleased designs, screenshots of internal tools, or anything under an agreement.
Every local method above avoids the question entirely.
Choosing a JPEG Quality
When you do convert to JPG, the quality number decides everything.
| Quality | Use for |
|---|---|
| 95–100 | Wasteful in almost all cases |
| 90–92 | Archival, or a master you will edit again |
| 80–85 | The default for the web |
| 70–75 | Large background images that will be scaled |
| Below 70 | Visible blocking on skin and sky |
The difference between 85 and 95 is typically 40% more bytes for a difference you cannot see at normal viewing size. Our JPEG optimization guide covers chroma subsampling and the other settings that matter more than the headline number.
Do Not Do This Repeatedly
Every PNG → JPG → PNG → JPG round trip runs the lossy encoder again. Generation loss accumulates: edges get soft, colours drift, blocking spreads.
Keep one master in a lossless format — PNG, TIFF, or the original camera file — and generate the JPGs from it every time. Never edit a JPG and re-save it as a JPG more than once or twice.
Both Are Usually the Wrong Answer for the Web
If the image is going on a web page, neither PNG nor JPG is optimal in 2026.
WebP is 25–35% smaller than JPEG at the same quality, supports transparency, and works in every current browser. AVIF is smaller still, at the cost of slower encoding.
# The conversion that actually helps a web page
magick photo.png -quality 82 photo.webp
magick photo.png -quality 55 photo.avif
Serve those with a JPG or PNG fallback in a <picture> element. See converting images to WebP for the bulk workflow, and the responsive images guide for the markup.
Summary
The Nine Methods
| # | Method | Use it when |
|---|---|---|
| 1 | Browser converter | Fast, private, any platform |
| 2 | macOS Finder Quick Action | The macOS batch answer |
| 3 | sips |
Scripted macOS jobs |
| 4 | Windows Paint and Photos | One or two files |
| 5 | PowerToys Image Resizer | The Windows batch answer |
| 6 | ImageMagick | Full control, including flatten colour |
| 7 | Python and Pillow | Inside a program |
| 8 | GIMP Script-Fu | GIMP is already installed |
| 9 | Online converters | Public images only |
Checklist
- ✅ The direction is right — photos to JPG, anything with text to PNG
- ✅ Transparency was flattened onto a chosen colour, not left to chance
- ✅ Semi-transparent edges were composited with the alpha as a mask
- ✅ JPEG quality is 80–85 for the web, 90+ for a master
- ✅ JPG to PNG was done for a real reason, not to “improve quality”
- ✅ A lossless master exists, so no round trips are needed
- ✅ The web version is WebP or AVIF, with PNG or JPG as fallback
For a batch: magick mogrify -format jpg -quality 85 -background white -alpha remove -alpha off *.png. That one line handles the direction most people need and the trap most people hit.
Related Resources
Related Guides
10 Ways to Convert Any Image to JPG on Any Device
8 Ways to Convert WebP to PNG or JPG (and Why Sites Serve WebP)
PNG Optimization: Transparency Done Right
JPEG Optimization Mastery: The Definitive Guide
Understanding Image Compression: Lossy vs Lossless Deep Dive
12 Image File Types Explained: When to Use Each