0

I have a web gallery where I display images which vary in file sizes and resolutions uploaded by users. Currently all the images are baseline. So I would like to know whether it would really have any significant impact if I converted them to progressive images. What are the advantages and tradeoffs on using progressive images.

Ayan
  • 2,738
  • 3
  • 35
  • 76

2 Answers2

9

The JPEG standard defines a variety of compression modes. Only three of these are in widespread use:

  • Baseline Sequential
  • Extended Sequential
  • Progressive

The only difference in the first to is in the number of tables allowed. Otherwise, they are encoded and decodes in exactly the same way.

JPEG divides images into Frames that are then divided into Scans. The modes above only permit one frame. The frame is the image. The scans are passes through the image data. A scan may be contain the data for one color component or it may be interleaved and contain data for multiple color components.

  • A grayscale sequential JPEG stream will have one scan.
  • A color sequential JPEG stream may have one or three scans.

JPEG takes 8x8 blocks of pixel data and applies the discrete cosine transform to that data. The 64 pixel data become 64 DCT coefficients. The first DCT coefficient is called the "DC" coefficient and the other 63 are called "AC" coefficients.

This is confusing terminology that drawing on the analogy with DC and AC current. The DC coefficient is analogous to the average pixel value of the block.

In sequential JPEG, the 64 coefficients in a block are encoded together (with the DC and AC coefficients encoded differently). In Progressive JPEG, the DC and the AC coefficients scans encode bitfields (of configurable size) within the coefficient. In theory, you could have a separate scan for each bit of each component.

Progressive JPEG is much more complicated to implement and use. If you are creating an encoder for sequential JPEG, you just need to give the caller the option to use interleaved or non-interleaved scans. For progressive JPEG your encoder needs a mechanism to the caller to determine how many scans and what bits should be encoded in each scan.

Progressive encoding can be slower than sequential because you have to make multiple passes over the data.

The speed issue in progressive decoding depends upon how it is done. If you decode the entire image at once, progressive is possibly marginally slower than sequential. If your decoder shows the image fading in as it processes the stream it will be much slower than sequential. Each time you update the display, you have to do the inverse DCT, upsampling, and color transformation.

On the other hand, it is possible to get much better compression using progressive JPEG with well-tuned scans.

There is no difference in quality between progressive and sequential

This book describes the processes:

https://www.amazon.com/Compressed-Image-File-Formats-JPEG/dp/0201604434/ref=asap_bc?ie=UTF8

user3344003
  • 20,574
  • 3
  • 26
  • 62
0

The only difference is that progressive images are encoded in a way that allows browsers to display a rough preview of the image while it is still being downloaded, which becomes progressively better in quality until finally the download is complete. A baseline image will load from top to bottom, a progressive image will load from low-resolution to high-resolution.

For browsers which do not support progressive images, you won't see anything until the entire image has been loaded. (Nowadays all halfway modern browsers support progressive JPEGs.)

You can see animations of the difference in action, e.g. here: https://www.youtube.com/watch?v=TOc15-2apY0

deceze
  • 510,633
  • 85
  • 743
  • 889
  • So is there any difference in terms of speed? – Ayan Dec 02 '16 at 12:45
  • Download speed? That depends on the size of the image, which depends on how you compress/save it exactly. Same sized files download in the same amount of time. Processing speed? Hardly worth talking about. – deceze Dec 02 '16 at 12:46
  • So if you were to use jpegs in the gallery would you prefer lazy loading of baseline jpegs or progressive jpegs. – Ayan Dec 02 '16 at 12:49
  • I don't think I would care very much and would rather try to find the right balance between size and quality and work on the fastest possible delivery mechanism through a CDN. – deceze Dec 02 '16 at 12:50