JPG, JPEG, and PNG are letters often found attached to the end of an image file name on your phones, laptops, PCs, or any digital device. Roughly, we know that they are formats associated with image files. But beyond that, you won't have much knowledge about the image format unless you are working in a graphics-related industry or photography industry. Information like: Why do some images appear to have a .jpg extension while others have a .png extension? What makes them so different that not all images get saved with a .jpg? Can they be used interchangeably? How do we choose between the two? All these questions get answered in this article.
JPG (Joint Photographic Experts Group) and PNG (Portable Network Graphics) are image files, specifically, they are raster image files. There are two types of image files raster and vector. Being a Raster image file indicates that the images are created using a specified number of colour pixels. In addition, raster files permit a great amount of detail to be displayed on the images, however, the images might lose their quality and resolution as they are compressed. In contrast, being a vector file means the images are made up of grids, mathematical formulas and points.
There is some basic information that can help in choosing between PNG, JPEG and GIF. If you need it for photographs, pick JPG. For line art, logos, transparent images, or images comprising huge amounts of text, choose PNG. For using an animated picture, choose GIF.
JPG vs. PNG
JPEG and PNG are both used for storing image files. A JPEG uses a lossy compression technique for resizing images. This means that the image files can be resized into smaller sizes and hence helps in storage purposes. However, lossy compression has some pitfalls; certain information from the images will be lost. Also, the image becomes degraded after multiple saves and compressions. The use of lossy compression also means that, even if the images were to be decompressed, they can never be returned to their original quality. In addition, JPEGs do not support transparency, that is, they cannot be used with images that have a transparent background. However, if you want to retain a white background for your photo, then JPG is the optimal choice. Because of their EXIF feature, JPGs are often used with photographs, because they help to provide additional information like the focal length used for the picture, when and where the picture was taken, etc.
In comparison, PNGs use a lossless compression technique for resizing and storing images. Lossless compression means that the image never loses any of its details, no matter how many times it is re-seized or resaved. This means that a PNG file will have better quality than a JPG file. Further, if the image were to be decompressed, it would revert to its original quality. However, because of this feature, a PNG file cannot be resized to have extremely small file sizes. Additionally, PNGs support transparency. That is, they can be used with images containing a transparent background. They are particularly useful for creating logos. Having said so, one feature that PNGs lack that JPEGs have is the EXIF feature.
Difference between JPG and PNG in Tabular Form
|Parameters of Comparison||JPG||PNG|
|Full form||Joint Photographic Experts Group||Portable Network Graphics|
|Compression Method||Lossy (DCT-based)||Lossless (DEFLATE compression)|
|Format||.jpg, .jpe, and .jpeg||.png|
|Image details||Image details get lost after many decompressions||The image details and quality remains the same.|
|Transparency||Doesn’t allow transparency||Allows transparency|
|Usage||Photographs; images with loads of colours||Line art; icon creation; transparent images; images with text|
|Magic number||ff d8||89 50 4e 47 0d 0a 1a 0a|
|Uniform type identifier||public.jpeg||public.png|
|Other versions||JPEG-HDR (supporting HDR)||MNG, APNG (Supporting animations)|
What is JPG?
JPG or JPEG is named after its creators, the “Joint Photographic Experts Group,” who developed it in 1992. The acronym JPEG is pronounced as “jay-peg.” In simple terms, .jpg is a file extension that is used to save images. It was created to reduce the sizes of large photographic files, to make it easier to share the files.
When digital photography got developed, they used Bitmap BMP files to store information. One major drawback of this technique was that it required huge amounts of storage space. Therefore, to reduce the file sizes of images, JPEG was developed.
In 1983, a few researchers associated with the International Organization for Standardisation set the course for the development of JPEG files. They were trying to develop new ways to include photo-quality graphics on text-only computer screens.
Three years after this experiment, the Joint Photographic Experts Group got established. The requirement for an image format that could shrink the file size but keep the picture quality led the group to develop the JPG image file type in 1992.
Compression of jpg files
“Compression” is the process of reducing the sizes of digital data (for example, images) or changing their attributes (file type, bit depth, dimensions, resolution, etc.) Two methods help in compressing files, lossy and lossless. The lossy compression method shrinks a file size by irreversibly deleting specific data. When decompressing the image file, deleted information does not get restored. Ergo, the lossy compression method is also called irreversible compression. In contrast, with the lossless compression method, no information is deleted when the file is undergoing compression. Also, when it is decompressed, it returns the file to its unedited version. Hence, the lossless compression method is also called reversible compression.
JPGs make use of a DCT-based lossy compression method. That is, the image size gets reduced by sacrificing its quality. Although the change in the quality of the image will not be readily noticeable with the first few saves, as the number of times the image is resaved increases, the image quality becomes worse. The image will become more pixelated and will not be able to display the original colours as it were. Therefore, never save the same jpg file multiple times. Although if you save the file multiple times without closing the actual file there won’t be any issues.
One advantage is that the compression of JPG files only affects the pixels of the image, not the colours. Therefore JPG is used with images containing lots of colours.
Features of JPG files
- File Size- JPG can shrink images into a feasible size. This feature is useful when you don't have much disk space. The smaller file size also helps to accelerate the rate at which your WebPages load. JPGs can support a maximum width and height of 65,535 pixels.
- Transparency- one drawback of JPG files is that they cannot support images with a transparent background. Therefore, JPGs cannot be used with non-rectangular logos and graphic images composed of a bunch of text. Further, it is not possible to use JPGs on web pages containing numerous background colours.
- EXIF- JPGs can embed EXIF data. EXIF data are used by digital cameras as a method for storing an image’s specific information. That is information about pictures such as where and when the photo got shot, shutter speed, colour profiles, focal length used for capturing the photograph, etc.
Uses of JPG files
- Majorly used with large images such as photos, graphic-heavy website backgrounds, etc.
- Used when you want the transparent portion of logos to stay white.
- Word documents
What is PNG?
The PNG, often pronounced ping, is an acronym for Portable Graphics. It was developed in the mid-1990 as a substitute for the graphics interchange format or GIF. PNG is a file extension that is used to store image files. It uses the format .png. PNG files are majorly used with web graphics, charts and illustrations, line art, logos, etc. They are also employed when the size of the image file is not an issue and if you are working with complex pictures. The major advantage PNG provides is that it can be used with transparent backgrounds, that is, it supports transparency.
In 1994, an internet working group led by Thomas Boutell got together to develop the PNG file format. During those days, GIF was the most widely used image format. The usage of GIFs had some complications, for example, it was owned by Unisys. As such web users could create, view, and forward GIFs, but no one was allowed to invent software to build them. Additionally, GIFs only had a colour range of 256 colours. Therefore, Boutell's group decided to create an image format that did not require a patent license. Another goal was to create an image format with increased colour support.
On January 4, 1995, the first preliminary outline for PNG got approved. In the following week, nearly all its features were proposed and accepted.
In March 1995, the ninth draft was proposed with all the necessary specifications and accepted.
Future versions were launched in the years 1998, 1999 and 2003.
Compression of PNG files
PNG files use the DEFLATE- lossless compression method. This means that the files don't lose data with every compression. The condition of the image file remains the same even after multiple edits. This is why PNGs are chosen for making graphs, logos, images with figures, etc. Further, when you decompress a PNG file, it will be returned to its original state and quality without any damage.
Features of PNG files
- File Sizes- because they operate on a lossless compression method and retain a great amount of information, PNGs tend to have bigger file sizes. As a result, they tend to take extra storage space, leading to a slower response by WebPages.
- Transparency- PNGs support transparency. This transparency feature is PNGs greatest benefit. It allows web designers to use transparent backgrounds with their images. It even supports the use of different levels of transparency.
- EXIF- PNG cannot embed EXIF data.
Uses of PNG files
- PNG files are used with small images, for example, web icons.
- Word documents
- Creating logos
- Web graphics
- For online charts and graphics
- Scanning printed texts (newspapers, handwritten documents, etc.)
Other Versions of PNG and JPG
In addition to the jpeg and png we commonly see on our devices, there are a few more. For example, there is an unofficial version of JPG capable of supporting HDR called "JPEG-HDR." Further, there are also versions of JPG that use lossless compression instead of lossy compression.
In the case of PNG, its developers created an animation-friendly format in 2001 called “Multiple-image Network (MNG).” In addition there is a nonstandard version of the PNG capable of showing animations like GIFs. This version is called "APNG".
While they provide these extra features, not every browser supports the versions.
Main Differences between JPG and PNG (in Points)
- THE FULL FOR OF jpg IS Joint Photographic Experts Group. The full form of PNG is Portable Network Graphics.
- Formats of JPG are .jpg, .jpe and .jpeg. The extension of PNG is .png.
- JPG is majorly used with photographs, while PNG is used with transparent images or line art.
- JGP makes use of the lossy compression process while PNG uses the lossless compression method.
- JPG loses quality and information the more its compresses and resaved. PNG does not lose any data.
- Overall file size of a JPG file is smaller as compared to a PNG file.
- A JPG does not allow for transparency. A PNG file can be used for transparency.
- The uniform type identifier of JPG is public.jpeg. The uniform type identifier for PNG is public.png
In conclusion, while both JPG and PNG are image formats, they have numerous differences. One is used for photographs while the other is used with logos and lime images. JPG use a lossy compression method, resulting in data loss while PNGs use a lossless compression method, retaining all the details. JGPs support EXIF but do not support transparency. PNGs do not support EXIF but support transparency.
In the end, choosing between the two involves what kind of image you want to save (photographs or icons), whether you want the transparency feature, and the disk space you are willing to sacrifice for the file.