ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

Question: Does iipsrv support lossless WebP format? #263

Closed BeebBenjamin closed 5 months ago

BeebBenjamin commented 10 months ago

I am looking into different formats for the best choice to store normal map data for 3D IIIF. I managed to get libwebp compiled and built into iipsrv, and I can get webp format tiles, however, even with WEBP_QUALITY="100" the tiles look lossy in the three.js shader; this makes me think that by default webp format is requested as lossy by iipsrv.

Does iipsrv support lossless WebP format?

ruven commented 10 months ago

You're right: iipsrv was setup to use lossy compression for WebP. However, I just pushed a commit (https://github.com/ruven/iipsrv/commit/5be79279160c772da958a1589a8fdf3d85fadbb3) that allows you to also specify lossless encoding!

Just set WEBP_QUALITY=-1 and tiles will be output with lossless compression. If you want to set this on a per-request basis, you can do this through the IIP API by setting the QLT query parameter to -1.

BeebBenjamin commented 10 months ago

That seems to have fixed this, huge thanks for the quick response!

ruven commented 10 months ago

By the way, a highly efficient way of doing this, would be to encode the TIFF image containing the normal map data with lossless WebP-compressed tiles. You can generate a lossless WebP TIFF using vips like this:

vips tiffsave --tile-width 256 --tile-height 256 --pyramid --lossless --compression webp input.png output.tif

The latest github version of iipsrv has a new pass-through mode, which allows pre-encoded tiles within a TIFF to be directly sent to the user without re-encoding if no image processing is needed. As WebP encoding is relatively slow, this would give you a noticeable speed gain. This short-cut only works for requests that map exactly to an existing tile in the TIFF pyramid structure - which should be the case if your tile requests are being made by a pan and zoom viewer.