In digital images, two image formats dominate over everything else: JPG (or JPEG) and PNG. Here’s what you need to know about PNG and JPG?
At first glance, a single image displayed in JPEG and PNG format may look the same. But if you look closely enough and examine the details, you can see that there is quite a difference between them. One format is not always better than the other. That’s because each one is tailored to different needs. Here’s what you need to know about JPEG and PNG to make the most of their strengths and weaknesses.
What is the JPG/JPEG format?
Short for Joint Photographic Experts Group, the team that developed the format, JPEG has become the standard compressed format for digital photography and online image sharing thanks to its careful balance between file size and image quality.
The exact ratio varies depending on the program and settings used. But a typical JPEG image has a compression ratio of 10:1. If you start with a 10MB image and export it as a JPEG, you should end up with an image of about 1MB. Depending on the content of the original image and the file type, the JPEG should have almost zero perceptible difference in quality.
To do this, JPEG relies on a discrete cosine transform. While the math behind it is complex, this compression algorithm looks at the whole image. It determines which pixels in the image are similar enough to those around them and combines the pixels into bins (groups of pixels with the same value).
This method is extremely efficient. But it comes at the cost of discarding information that you cannot retrieve. JPEG images (with a few exceptions mentioned below) are lossy. This means that data lost after the image is saved cannot be recovered. So every time you open and save a JPEG, just like photocopying a photocopy of a photocopy, it will look a little worse than before until you eventually lose all the details.
For this reason, JPEG is not recommended as an archive image format. Because if you need to open it and edit it again, you will lose quality. Photo editors like Adobe Lightroom can help you overcome this problem, provided you never delete your original files. This is because they only save edits as metadata instead of overwriting the original image.
JPEG should also not be used for text-heavy images or illustrations with sharp lines. Defined lines tend to blur due to anti-aliasing.
However, there may be times when you need to convert formats like PDF to JPEG. In these cases, it’s best to make sure you export at the highest quality settings to ensure all text is sharp.
JPEG supports both RGB and CMYK color spaces at 8 bits. But CMYK offerings leave much to be desired. Modern printers handle RGB files just fine. So this is not a big problem. But it will still help if you need higher quality formats for printing.
Many variants of JPEG have emerged over the years. For example, JPG-LS was designed to fix lossy compression. But it never gained traction and eventually died out. JPG 2000 also tried to solve the lossless problem, but it too failed to gain traction.
In JPEG XS the compression is only six times instead of 10. But simpler algorithms mean the file is faster for streaming tasks. Where others have failed, HEIF can succeed thanks to the backing of one of the biggest brands in technology: Apple. It still has a way to go. But more image editing programs and more devices are adding support for the new format, such as JPEG Pleno, which offers users an excellent toolset that includes holographic imaging, texture plus depth, point clouds and light fields.
What are the pros and cons of the JPEG format?
Pros
Small file size
Integrated EXIF support
Widely supported
Cons
Lossy compression
Not great for CMYK printing
No transparency support
What is the PNG format?
PNG, short for Portable Network Graphics, is a lossless file format designed as a more open alternative to Graphics Interchange Format (GIF).
Unlike JPEG, which relies on DCT compression, PNG uses LZW compression, the same as the GIF and TIFF formats. In a nutshell, PNG’s two-stage LZW compression takes the bit sequences contained in the image’s data, then maps these long sequences to accompanying short codes held in a dictionary (sometimes called a codebook) stored in the image file. The result is a smaller file that retains high quality.
The main advantage of PNG over JPEG is that the compression is lossless. So there is no loss of quality each time it is opened and resaved. PNG also renders detailed, high-contrast images well. For this reason, PNG is the default file format for screenshots, as it can provide an almost perfect pixel-perfect representation of the screen, rather than compressing groups of pixels together.
One of the highlights of PNG is its support for transparency. In both color and grayscale images, pixels in PNG files can be transparent. This allows you to create images that neatly overlap with the content of an image or website. Many editing programs use a gridded background to indicate the transparency of a graphic. This makes PNG great for logos used on a website, especially those with text. On the other hand, if you create a transparent background in Photoshop and save the images as JPGs, this transparent background will be white because the format does not support transparency.
When it comes to photography, PNG may seem like a solid alternative to proprietary RAW formats for lossless image storage. Truth be told, there are plenty of better alternatives, such as Adobe’s Digital Negative (DNG) and TIFF. PNG also doesn’t natively support EXIF data, which contains information about the camera that took the photo, such as shutter speed, aperture and ISO.
PNG was made for the web and has proven its worth. JPEG can be the format for most images. Yet PNG covers a significant area that JPEG can’t effectively reach. It is basically the only option when you need to render a logo or text clearly over other elements on a website.
Like JPEG, PNG has had several variations over the years. APNG is a currently supported format designed to replicate the animated functionality of GIFs. It is not common but is supported by many modern browsers.
Pros
Lossless compression
Transparency support
Great for text and screenshots
Cons
Larger file size than JPEG
No native EXIF support
What is the difference between JPEG and PNG and which is better?
In conclusion, one is not better than the other in JPEG and PNG image formats. What matters is which one is more suitable for your needs.
If you want to share a photo from your camera on Instagram, Twitter, etc., your best option is to use JPEG. It’s smaller in size, optimized for photography. It’s widely supported on almost every platform and service imaginable.
If you are taking a screenshot that you plan to annotate or archive for later use, a PNG will better suit your needs. The file size can be larger than an equivalent JPEG. But you don’t have to worry about it losing quality every time it’s resaved. You also know that every pixel is as sharp as the last time you opened it. Like logos, most web graphics are better saved as PNGs because they can take advantage of transparent areas.
New “Alien” TV series will take place 30 years before the first “Alien” movie
The post What are JPEG and PNG? Which Image Format Should You Use? appeared first on NSF News and Magazine.