Eli5: What’s the difference between a png and a jpg

570 views

Obviously there is some type of difference, otherwise there wouldn’t be two different image types, but I’ve never been explained what the difference is.

In: Technology

7 Answers

Anonymous 0 Comments

The primary difference that relates to most people is that png can have a transparent background. So if you have your logo in png format you can easily overlay it on top of another image. Jpg can’t do that.

Anonymous 0 Comments

As a general rule PNG handles large areas of flat color (think cartoons and similar drawings) better, and JPG handles photo-real images better. There will of course be some exceptions to this. PNG also allows for transparency which makes them useful for certain things you can’t do with JPGs (irregular shapes, frames, screens, etc.).

Anonymous 0 Comments

JPG uses a lossier compression than PNG, which compress very little. Highly compressed JPG images look pretty bad and you can’t have transparent images, but they’re *way* smaller files which matters a lot when you have lots of them and you have limited bandwidth or drive space.

Anonymous 0 Comments

PNG is “lossless” – there’s no compression or loss in quality from the original source file. It also allows for fancier photo editing (having more advanced color scales/palettes, allowing for different transparency settings for the background of the picture, etc.). But, it tends to be a larger file size.

JPG is “lossy” – it *does* compress a picture which can have an impact on the quality of the image. That difference isn’t always so noticeable to the human eye, though, it all depends on the picture in question. It’s not as diverse as PNG as far as how you can fine-tune the picture quality, but it does usually have smaller file sizes.

Anonymous 0 Comments

The type of compression used.

PNG uses a lossless method. All the information is still there, just saved in a more efficient way.

JPG uses a lossy method. You lose some information, but JPGs take less space. It’s very noticable when the image includes some text. You’ll note some compression artefacts around it.

Anonymous 0 Comments

They use different compression algorythms. Because of this JPG images lose some quality during compression to make them “lighter” (less MB), while PNG images don’t lose quality. They are a bit heavier as a result though.

Anonymous 0 Comments

They are different algorithms for storing a picture.

You *could* store a picture with all the RGB values in full for every single pixel, but that would make a 12 megapixel photo (like the ones from the latest model of iPhone) 36 megabytes in size.

Instead, we use compression algorithms to better store photos.

You may think of compression as things like ZIP files. Those are general compression algorithms that try and replace common recurring data with shorter references to an index. However, when you are working with a specific data format, you can use the properties of that data format to help with compression.

For instance, with a picture, you know that most of the time a pixel will be very similar to the one next to it, so you can only store a smaller value that has the difference between it and the pixel before it. You repeat this enough times, and you can save a significant amount of the file size.

PNG and JPG are two different algorithms for storing pictures. The main difference between the two is that JPG is a lossy algorithm, whereas PNG is lossless. Basically, if you take that raw 32MB photograph and save it as a PNG, every single pixel in that PNG will be the exact colour it was in the original photo. This is just like how a ZIP file perfectly extracts into what it was originally.

A JPG photo, on the other hand, is a lossy algorithm. It works on the principle that not every pixel needs to be 100% exact compared to what it originally was, just close enough that the feel of the original image is maintained. This is especially useful when the 12MP photo is looked at on a screen that is nowhere near large enough to display every pixel, so you don’t even need to be perfectly accurate.