Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have to decide between PNG or JPEG image format for the pictures that my project will work with.
I've been testing the conversion of the same pic to this formats, different ppp config, and all the results says that i can get a good resolution with JPEG with so much less image space.

Certainly, PNG is a "lossless compression format", and JPEG gets more compressed images… but what I haven’t readed anywhere is if this compression means different performance impact to my project.

What I have tried:

This is my example, an image with 982x650 pixels, at 175ppp

PNG file -> 1582kB
Jpeg file -> 141kB

The difference is clear. And that’s my question: This difference of size means that my program will “decompress” the jpeg files before using it? The PNG files will be faster because is less compressed?


Searching, I’ve founded this link, hope it was helpful for us too. Learn When to Use JPEG, GIF, or PNG with This Graphic
Updated 29-Jun-20 11:43am
F-ES Sitecore 4-Apr-16 10:51am    
Use the Stopwatch class to time your own tests and see for yourself. Get a bunch of sample images and compress\show them a couple of thousand times in a loop and time how long it takes for jpg vs png.
Ivan_FM 4-Apr-16 10:57am    
ok! That's a good point, I will try it and then I will tell us how it goes ;)

You already got a good link describing the differences.

When images are displayed by an application they have to be converted to bitmaps using the colour depth of the graphic system. Because this is usually 24-bit nowadays (8 bit per RGB channel), preparing the images with that colour depth is a good start. Converting a PNG image to a bitmap is really fast when the colour depth matches and the image has not to be scaled. A compressed image must always be decrompressed which tooks some time. But this should be no problem with common systems.

As already mentioned, scaling took some processing time too. While the times are again usually not a problem, proper scaling avoids artefacts and may reduce the image size.

My suggestions:

  • If necessary convert images to 24-bit colour depth (32-bit with alpha channel).
  • Scale the images to the final resolution.
  • Choose the format according to the tips from the link: JPEG for (very) large images like photos and PNG for small and medium size images (graphics).
Share this answer
Performance issues makes little difference on modern cpu's so the only real question is your storage size.

In any case most modern libraries support all the formats and most are baked in to the frameworks.

If in doubt support all formats and let your users decide.
Share this answer
The choice PNG/JPG very much depends on circumstances:

1. image quality
you loose some when using compression.
it would not be a good idea to use JPG for a screen shot of a text document with small font sizes.

2. performance
what are you doing with those images?
are they being transmitted over a potentially slow or expensive connection? if so, file size is what matters most.
are they just stored and used locally on a typical PC? if so, its all the same, there is ample disk space and speed, memory, compute power.

In summary: the fact that several solutions exist typically means there is no ideal solution, each of them has advantages and disadvantages; so consider what is most important to you and act accordingly.
Share this answer
- Best for natural images (photos).
- Do not support transparence.
- Adjustable size. Less size, less quality.

- Best for sintetic images (Line art, Computer Graphics, icons, etc...).
- Support transparence.
- Ever perfect quality.
- You can reduce the zise with PNGour, TruePng and similar programs.

The performance are allways good in any PC.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900