Evaluating JPEG, WebP, and AVIF

After making some improvements to the PDF thumbnails in DSpace 7.5 and DSpace 7.6, I wanted to explore some of the ideas I had highlighted for future work. One of the most promising improvements is switching from the JPEG image format to a more modern format, such as WebP, AVIF, or JPEG-XL.

In brief, JPEG is an older image format, while WebP, AVIF, and JPEG-XL are each successively newer and more advanced. These newer formats provide similar visual quality to JPEG but with smaller file sizes. However, the level of support for these formats varies, with only WebP and AVIF having gained broad support in client-side applications like web browsers.¹

Based on my evaluation of WebP and AVIF against JPEG using a representative sample of real PDFs from our institutional repository, I recommend that DSpace default to WebP as its image format for PDF thumbnails.

― Alan Orth (@alanorth), 2023-05

Background and Methodology

More than a decade ago, Google conducted their second major WebP compression study. Although much time has passed, the methodology remains relevant: because "quality" settings between image formats are not consistent, we must use a visual quality metric to establish equivalent "quality" settings for each format before we can compare compression results accurately. For example, JPEG Q92 is not the same as WebP Q92 or AVIF Q92. The current state-of-the-art perceptual quality metric is ssimulacra2 (v2.1) by Jon Sneyers.

Using a sample size of thirty-five PDFs I performed thumbnail operations at quality settings one to 100 for JPEG, WebP, and AVIF with ImageMagick. For each source PDF, I generated a lossless reference (PNG) and calculated the ssimulacra2 score for each thumbnail with regards to the reference. These tasks were broken up into individual "jobs" and submitted to a local process queue called pueue. Needless to say, managing this workflow and the nearly 11,000 jobs became a significant part of the analysis!² Results were saved to CSV and plotted using gnuplot.

Bits Per Pixel (BPP)

For each of the thirty-five PDFs, I calculated the average ssimulacra2 scores for quality settings 1 to 100 for each image format relative to a lossless reference. Then I plotted the ssimulacra2 scores against the average number of bits per pixel (BPP) needed by each format:

gnuplot graph showing average ssimulacra2 scores versus average bits per pixel (BPP) for JPEG, WebP, and AVIF.

From the above it is obvious that both WebP and AVIF outperform JPEG in terms of BPP: they both need less bits to achieve the same perceptual quality as JPEG.

Another way to visualize the same is by plotting the average file size in bytes versus average ssimulacra2 scores:

gnuplot graph showing average sizes in bytes versus average ssimulacra2 scores for JPEG, WebP, and AVIF.

Equivalent Quality Settings

We can also see that both WebP and AVIF have diminishing returns after achieving a ssimulacra2 score of around 80. According to ssimulacra2, scores can range between -infinity and 100, with 70 being "high quality" and 90 being "very high quality". For the purpose of this evaluation I will assume that a score of 80 is reasonably high enough. In any case, it seems that WebP (in particular) and AVIF have trouble achieving "very high quality" scores—with this dataset at least:

gnuplot graph showing average ssimulacra2 scores versus quality for JPEG, WebP, and AVIF.

Using a ssimulacra2 score of 80 as the target perceptual quality gives the following equivalencies between "quality" settings for each format:

Summary of Findings

After establishing equivalent "quality" settings for JPEG, WebP, and AVIF for this dataset, we can see that WebP and AVIF require 33% and 46% less bits than JPEG, respectively, to achieve a ssimulacra2 score of 80. A score of 80 falls between the "high quality" and "very high quality" brackets on ssimulacra2's scoring scale. We observed that WebP and AVIF have problems reaching "very high quality" scores, which may or may not be a problem depending on application requirements.

Finally, while AVIF may be compelling technically, according to caniuse.com's data about web browser share and feature implementation, support is still too low to consider in practice. Many DSpace repositories are deployed in developing country or corporate settings where users may not have the latest web browsers.

The thumbnails below are 800 pixels on their longest side — usually height — and are rendered at 400 pixels in CSS for crispness and ease of comparison here. Use the slider overlay on each image to compare the JPEG with the WebP version of each thumbnail.

Note: As DSpace 7.5 uses the default ImageMagick quality setting of 92 for JPEG thumbnails, I use that for the comparison here. For the WebP thumbnails I use a quality setting of 86, which I found to be sufficient in my tests above.


The goal of this thumbnail gallery is not to perform an "apples to apples" comparison, but to show how WebP compares visually to existing DSpace JPEG thumbnails. This approach gives JPEG an advantage when it comes to visual quality and a disadvantage on file size. 🤷

10568/103447

Notes:
WebP size: 88134 bytes (48% smaller)
JPEG size: 167776 bytes

10568/116598

Notes:
WebP size: 29478 bytes (58% smaller)
JPEG size: 69653 bytes

10568/3149

Notes:
WebP size: 103088 bytes (43% smaller)
JPEG size: 178210 bytes

10568/51999

Notes:
WebP size: 95310 bytes (46% smaller)
JPEG size: 175459 bytes

10568/53155

Notes:
WebP size: 36022 bytes (57% smaller)
JPEG size: 83531 bytes

10568/68624

Notes:
WebP size: 85676 bytes (48% smaller)
JPEG size: 164226 bytes

10568/68680

Notes:
WebP size: 119828 bytes (47% smaller)
JPEG size: 223612 bytes

10568/71249

Notes:
WebP size: 59724 bytes (54% smaller)
JPEG size: 129704 bytes

10568/72646

Notes:
WebP size: 75162 bytes (53% smaller)
JPEG size: 158742 bytes

10568/75477

Notes:
WebP size: 38652 bytes (63% smaller)
JPEG size: 102758 bytes

10568/76976

Notes:
WebP size: 91530 bytes (52% smaller)
JPEG size: 187018 bytes

10568/77628

Notes:
WebP size: 108646 bytes (46% smaller)
JPEG size: 201375 bytes

10568/97925

Notes:
WebP size: 86518 bytes (50% smaller)
JPEG size: 170560 bytes

10568/108972

Notes:
WebP size: 82240 bytes (55% smaller)
JPEG size: 180837 bytes

10568/3030

Notes:
WebP size: 90372 bytes (48% smaller)
JPEG size: 174172 bytes

More Information

The thumbnails in this gallery were generated by the src/create-thumbnails.sh script using PDF bitstreams from the CGSpace repository. The scripts to reproduce the results are available on GitHub.

Upstream Progress

Future Work

Future work may include: