PNG vs. JPEG
The short answerPNG uses lossless compression and supports transparency, so it suits logos, icons, screenshots and text. JPEG uses lossy compression that makes photos much smaller, but it has no transparency and can blur sharp edges.
PNG and JPEG are the two classic raster image formats of the web, and every browser, operating system and image editor supports both. They were built for different jobs: JPEG was designed in the early 1990s to shrink photographs, while PNG arrived in the mid-1990s as a patent-free, lossless replacement for GIF. People compare them when deciding how to save or export an image, because the wrong choice leads to bloated files or blurry graphics.
| PNG | JPEG | |
|---|---|---|
| Compression | Lossless: every pixel is stored exactly | Lossy: discards detail the eye is less likely to notice |
| Transparency | Full alpha transparency, including partly transparent pixels | Not supported; transparent areas become a solid color |
| Best suited to | Logos, icons, screenshots, diagrams, text and flat colors | Photographs and images with smooth gradients and fine texture |
| File size for photos | Often much larger than a comparable JPEG | Small, with a quality setting that trades size for detail |
| Repeated editing | Can be opened and saved again with no loss | Each lossy re-save can add more compression artifacts |
| Color depth | Up to 16 bits per channel, or an indexed palette of up to 256 colors | Usually 8 bits per channel |
| Typical artifacts | None from compression | Blocky patches and halos around sharp edges and text |
| Origin | Mid-1990s, as a patent-free replacement for GIF | 1992 standard from the Joint Photographic Experts Group |
How PNG works
PNG compresses image data with the DEFLATE algorithm, the same lossless method commonly used in ZIP files, after a filtering step that makes rows of pixels easier to compress. When the image is decoded, every pixel comes back exactly as it was saved. PNG can store full-color images, grayscale images and images limited to an indexed palette, and an alpha channel lets each pixel be anywhere from fully opaque to fully transparent.
Lossless compression works very well on large areas of flat color and repeated patterns, which is why screenshots, logos and diagrams compress well as PNG. It works poorly on the random-looking detail of a photograph, so a photo saved as PNG is usually much larger than the same photo saved as a JPEG.
How JPEG works
JPEG splits an image into small blocks, converts each block into frequency components with a discrete cosine transform and then rounds away the fine detail people are least likely to notice. It usually also stores color at a lower resolution than brightness, because the eye is more sensitive to changes in brightness. A quality setting controls how much is thrown away, so the same photo can be saved as a large, near-perfect file or a small one with visible flaws.
This approach is very effective on photographs, where small losses are hard to see. On sharp edges, text and flat color it produces artifacts such as blocky patches and halos. JPEG has no transparency, and because the compression is lossy, opening and re-saving a JPEG can reduce its quality a little more each time.
When to choose PNG
Choose PNG for images made of sharp lines, text and solid colors, such as logos, icons, interface screenshots, charts and diagrams. It is also the right choice when you need transparency, for example a logo that has to sit on different background colors, and as a working format for images you plan to edit and save many times.
For small graphics with few colors, saving a PNG with an indexed palette can make the file much smaller with no visible change. Avoid PNG for large photographs on a website unless you need perfect fidelity, because file size affects how quickly pages load.
When to choose JPEG
Choose JPEG for photographs and other continuous-tone images, such as product photos, portraits and landscapes, especially when they will be shown on the web or sent by email. A moderate quality setting usually produces a file that looks the same as the original at normal viewing size while being far smaller than a PNG.
Keep an original copy and export JPEGs from it rather than repeatedly editing and re-saving the same JPEG. Many cameras save photos as JPEG, and the format can carry Exif metadata such as the camera model and the date a photo was taken.
The verdict
Use PNG when an image needs exact edges, readable text or transparency, and use JPEG when it is a photograph and small file size matters more than perfect fidelity. Many sites use both: PNG for logos and screenshots, JPEG for photos. Newer formats such as WebP and AVIF can handle both kinds of image, but PNG and JPEG remain the formats that open everywhere.
Published