Do you like Photoshop? Or, maybe you are a photographer? A designer?

Even being an average computer user, you might run into a problem of how is better to save pictures that you have created in your editor programs. What is the difference between all of those formats and which one of them to use?

There are two most common image formats called JPEG and PNG. Is JPEG or PNG better?

In this thread, we are going to answer the following questions :

  • What is the difference between JPEG and PNG?
  • How does it work?
  • What’s better JPEG or PNG?
  • Is PNG higher quality than JPEG?
  • JPEG or PNG for print?

What is the point of file formats?

The major purpose of it is to compress the file. That way having raw images might be very ‘heavy’ for web use or just to hold it on your PC. It also takes a lot of space of any other storage like USB flash drive or micro SD which is commonly used for cell phones and photo cameras. JPEG format is capable of doing up to 100 times compression. If there would be no such thing as compression, you would not be able to download a website fast enough and you would feel how is it to be in the 1990s when the internet just appeared and everything was slow-paced.

Fortunately, technologies stepped up and all sorts of optimization have been taken for granted. Let us take a deeper look into certain image formats to understand how does it work.

The JPEG format

The JPEG image file format is developed by the J oint P hotographic E xperts G roup, that way it took its name as an abbreviation also known as the file extension for images ‘.jpg’. The JPEG format is capable of doing lossless and lossy compression, which one you choose defines the output file size and quality of an image. Nevertheless, it has its limitations and is only able to render images with resolutions up to 65535 × 65535 pixels, which is enough to cover all needs. Nowadays displays are mostly full HD or Ultra HD, 1920 x 1080 and 3840 x 2160 pixels accordingly, which is considered as high resolution. Thus we have a fairly large margin with JPEG.

How does it work?

JPEG is a genius technology and also simple at the same time. If we take a closer look at the raw picture as it is, we will notice that it consists of pixels. Every pixel of any image contains three colors: red, green, and blue. Every color is coded by an 8-bit number. Let us have a 1000x1000 pixels image on the screen. Since we know these numbers, it is not that hard to count the information “weight” of that picture: 8x3x1000 = 24 000 000 bits of information or 3 Megabytes. That way raw image file occupies a lot of storage space. But saved in JPEG format, this picture might be around 100 Kilobytes, which is about 33 times less capacity compared to a raw file. The quality of an image may also take some losses, but not that much. At 1st look, it appears to be some sort of magic, but since we are not in Hogwarts this can be explained and comprehended.

Stages of compression

The 1-st stage is transferring the image to a different color space. Speaking differently it is brightness and color separation. We illustrate it below to have a better representation of how it works. There are no quality losses in that step because each pixel still consists of three components but now it represents brightness and two color components instead.

To simplify the said, it creates a grayscale image and two colored masks.

But what is the point? The point is about how do we perceive images. It turns out that human vision is less sensitive to a color different than to a brightness difference. Considering that, we can throw away some color details using color masks. For that matter, here comes stage two called resampling. Resampling makes a job to combine every four pixels of the colored mask to become one.

As you can see in the illustration above, the resolution of the colors has changed, small pixels have become bigger but still represents the same colors. That way we can get about two times compression.

Resampling causes some color quality losses, but you will never see the difference with an unequipped eye.

The next stage is the division into blocks. If you take a look at the clean parts of the sky of the picture above, you may notice it has pretty much the same color all over the place. Here comes the conclusion: why would you code each pixel separately, if you can code a whole block of 8x8 pixels considering its similarity? That step also decreases image weight, depending on how many details appear to be in one block.

There are way more stages that we can take a look at, but those are using pretty much the same methodology of compression but only with much more math depth inside. Let us mention its names and move on: Discrete cosine transform, Quantization, Zigzag scan, Entropy coding, Huffman coding, final rendering. All of those stages let you compress images to a certain extent to have a good ratio between quality and file size.

The PNG format

There are a lot of image file format competitors along with JPEG, that is worth mentioning. Such as TIFF and GIF formats. They also have a common use, but all of them also have pros and cons. For instance, the TIFF format has a big output file size and GIF gets less of a color palette for the image. GIF has 256 colors compared to PNG’s 16.1 million colors. Thus, PNG took a good spot amongst told file formats, also having advantages over JPEG which we will discuss further. Considering that PNG can save color palettes better, compared to GIF. It would have replaced GIF format completely if there would not be such a thing as animation, which GIF format is capable of. Anyway, the PNG has its advantages and unique usage. Let us break it down.

PNG and its Lossless encode capabilities

The major con of using JPEG, that it does a worse job for images that contains a lot of small details such as numbers or letters on the image. It shows some noises around it, called artefacts.

You may also decrease the compression ratio to decrease noises saving your image as JPEG, but you can not be able to get rid of all of the artefacts completely.

Which is higher quality JPEG or PNG?

In order to compare JPEG vs PNG size and performance, we represent the picture below. The left one is saved with the best compression setting as JPEG and there is PNG right next to it. We have added some contrast filters to emphasize the difference in a spot where black and white pixels borderlines each other.

Is PNG better than JPEG?

In this way, the PNG format is being used mostly for scientific journals because small details look different on specific images depending on which format you use. As you can see there are no artefacts around ‘60° N’ and between the black and white areas of an image and text. That way we conclude about PNG vs JPEG quality. If you ask yourself is PNG better than JPEG, the answer would be more complicated than just YES or NO because it depends on what you use it for. Thus, PNG might be better for printing because of the more details represented in the image. But if we talk about image files in order to compare JPEG vs PNG size, JPEG could have an advantage here with good quality to compression ratio. For example, if you are an active Instagram user, and upload photos there consistently, you better have it in JPEG format.

PNG and Transparency, Conversion and Compress

Another advantage of the PNG format compared to JPEG is that PNG capable of saving the transparent background of the image file. Transparency will look like a chess field around the picture, thereby it represents no background, which means it can be filled with any background for certain needs without the picture itself editing.

To be sure that you have a PNG image, you can open it in Adobe Photoshop and you will see that the background layer is not locked there and you can fulfil it with anything you like. If opened image occurs to be JPEG format, you may need to manually separate the picture of the background using ‘polygonal lasso’ or ‘magic wand’ tools to replace it with something else, then save it as PNG. The most common way to define what image file format is in front of you is to make sure that you have opted for seeing file extensions in your operating system. If you choose to show extensions, there would be ‘.jpg’ or ‘.png’ after the file name, which represents its format. Example: ‘book.png’ or ‘book.jpg’. Using Photoshop you can also convert one file format into another and adjust compression settings there in order to get smaller or bigger file size depending on quality/compression settings. If you don’t know how to convert files, just look at the top left corner in Photoshop, then press ‘file’ - ‘save as’ - and there should be a section in the appeared window with all file formats available in Photoshop.

As we mentioned above, transparency has a good usage to fulfil an image with different background. But it also has a vice versa effect, when you can make a specific composition based on certain background. That way you add simple objects saved as PNG for your composition without additional work of making a transparent background for those objects.

Which is better jpeg or png?

We have compared PNG vs JPEG formats.

We came to the conclusion that all of them have different and specific usage.

If you like editing in such programs as Adobe Photoshop, you may use the RAW format in common. If you work with a website, you may take into consideration PNG and JPEG. For printing, when details matter the most, use PNG format. Just use Instagram and upload photos, then use JPEG. We hope this article has delivered a better understanding of the JPEG vs PNG difference.