Introduction

To comfortably view high-resolution images on the web, pyramidal structures (multiple resolutions) and tile segmentation are essential. In this article, we used vips to create pyramidal tiled TIFFs from JPEG2000 images and compared the file sizes of various compression methods.

Test Environment

vips Commands

JPEG Compression (Lossy)

#v#v#viiiQpQpQpusususaaaltltltiiiiiitftftfyfyfyfsss1a7a2a0v5v5v0eee(((ibihinnanineplpgpauauhurtnttl.c.c.yjejojpdpmpl2)2p2orsooeosuusulttsteppipsuuousttnt)__)_qqq1720550...tttiiifff---tttiiillleee---pppyyyrrraaammmiiiddd---cccooommmppprrreeessssssiiiooonnn===jjjpppeeeggg---QQQ===7215500

Lossless Compression

#v#v#viiiDpLpUpesZsnsfWclttotaicimitfofpfefmfrfspsescarasaovevsvmeseeepsdriiiienon(nspnpBpsuuiuittgto..T.njjIjppFp(22F2zloofoiuuoubttrt)ppmpuuautttt___dlrnezeofwqnl.ueati.tirtefei.dfti-iftf-itli-evlteeirl-ep4-yGprBy-a)rpmayimrdiadmi-dc-ocmo-pmcrpoermsepssriseoisnos=nil=oznnwo=ndeefl-abtiegtiff

Test Results

FileCompression MethodSizeRatio to OriginalNotes
OriginalJPEG2000274MB-Input
q25.tifJPEG Q=2557MB0.21xLossy, high compression
q75.tifJPEG Q=75167MB0.61xLossy, balanced
q100.tifJPEG Q=1002.4GB8.8xLossy, high quality
deflate.tifDeflate2.8GB10.2xLossless
lzw.tifLZW3.2GB11.7xLossless
none.tifUncompressed4.3GB15.7xLossless

Image Quality Comparison

We visually compared the differences in JPEG compression quality (from left: Q=25, Q=75, Q=100).

JPEG quality comparison (Left: Q=25, Center: Q=75, Right: Q=100)

At Q=25, noise is visible around character outlines, but at Q=75 and above, degradation is barely noticeable.

Discussion

JPEG Compression

  • Q=25: About 1/5 of the original file. JPEG-specific noise is visible in character outlines, etc. Suitable for preview purposes
  • Q=75: About 60% of the original file. Good balance between quality and size, recommended for most use cases (vips default value)
  • Q=100: Near-lossless, but file size is smaller than lossless compression

Lossless Compression

  • Deflate: Most efficient among lossless compression methods (2.8GB)
  • LZW: About 14% larger than Deflate (3.2GB)
  • Uncompressed: Exceeds 4GB, requiring BigTIFF format

Comparison with JPEG2000

The original JPEG2000 file (274MB) achieves very efficient compression. JPEG2000 uses wavelet transform, which is a different algorithm from TIFF’s JPEG compression (DCT transform).

However, JPEG2000 is not supported for direct browser display and requires tile delivery via an IIIF server. Pyramidal TIFFs can be used directly with many IIIF servers (such as Cantaloupe).

Use CaseRecommended SettingReason
Archival storageDeflateSmallest lossless size
Web delivery (high quality)JPEG Q=75-85Balance between quality and size
Web delivery (speed-focused)JPEG Q=50-60Fast transfer
Print useJPEG Q=90-100Maintaining high quality

Summary

Using vips, you can efficiently create pyramidal tiled TIFFs from high-resolution images. The choice of compression method should be based on the use case, and JPEG Q=75 is generally recommended for web delivery.

References