Web DevelopmentGraphic Design

JPG vs PNG: When and why to use each format

JPG vs PNG: When and why to use each format

When I started my graphic design career and had to include an image in one of my publications, I didn’t know which one to choose because at that time, I thought JPEG (JPG) and PNG were exactly the same. At first glance, they may seem similar to you as well, but if you look closely and dive into the details, there are certain differences.

I can’t say that one format is better than the other; each is designed to be used for specific tasks depending on the requirements. Here’s what you need to know about both formats to make the most of their features.

JPEG/JPG

JPEG stands 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 due to its careful balance between file size and image quality.

The exact ratio varies depending on the software and settings used, but a typical JPEG image has a compression ratio of 10:1. This means that if you start with a 10 MB image and export it as JPEG, you should end up with an image of approximately 1 MB. Furthermore, you should see almost no perceptible difference in quality, although this depends on the image content.

JPEG uses mathematical algorithms based on two visual phenomena of the human eye. The DCT (Discrete Cosine Transform) compression algorithm analyzes the entire image, determines which pixels are similar enough to their neighbors, and groups them into tiles (groups of pixels with the same value).

At first, you might think this format is perfect. But the significant downside of this method is that it discards information that cannot be recovered. This means that, just like making a copy of a copy, each time you open and save a JPEG file, it will look slightly worse than before.

JPEG should also be avoided for images with lots of text or illustrations with sharp lines, as the lines tend to appear blurry due to the intentional blurring designed to smooth out rough edges.

JPG 2000

In 2000, a new image encoding system was created based on JPEG but with added improvements for lossless compression, resolution and quality scalability, unlimited metadata, and handling larger image sizes. The disadvantages of this file type include compatibility issues, as not many browsers support it and most cameras are not designed to handle this format.

PNG

PNG stands for Portable Network Graphics, a lossless file format designed as a more open alternative to GIF.

PNG uses LZW compression, the same used by GIF and TIFF formats. In summary, PNG’s two-stage LZW compression takes bit strings contained in the image data, matches these longer sequences with shorter codes stored in a dictionary (sometimes called a codebook), and compresses the file while maintaining high quality.

PNG’s main advantage over JPEG is that there is no loss of quality each time a file is opened and saved. PNG also handles detailed, high-contrast images well. This is why PNG is often the default file format for screenshots, as it provides an almost perfect pixel-by-pixel representation of the screen, rather than compressing groups of pixels together.

Another standout feature of PNG is its support for transparency. With color and grayscale images, pixels in PNG files can be transparent, allowing for images to perfectly overlay on content of a webpage or image.

Example

For instance, this photo was taken by me at the recent Taylor Swift concert in Madrid. You can clearly see the difference in file size between the two formats. I’ve already resized this JPG in tinyjpg.com to make it more web-friendly 😉

JPG vs PNG: When and why to use each format

JPG vs PNG: When and why to use each format

How to convert files between formats?

Fortunately, JPEG and PNG images are not stuck in their file format permanently. You can always use Photoshop to convert your files, but if you’re not experienced with this program, you can use free online tools.

Here are some websites I recommend:

  • ILoveIMG : You can convert up to 15 files at once. If you sign up for a free account, you can convert up to 30 files at once.
  • Image Online Convert : Offers a free tool that allows you to convert up to 20 files at the same time without providing your email address. If you purchase the premium version, you can convert up to 200 files at once.
  • PNG2JPG : Allows you to convert up to 20 files at once. The free tool does not require your email address.

Come back soon for more lists and guides. And if you liked this article, share it on your social networks!