sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Enhancement: add support for WebP compression within TIFF output

Open joesong168 opened this issue 2 years ago • 2 comments

Actually vips support webp in pyramid tiff in certain platform like ubuntu but not windows. Is it possible for sharp to support webp in all platform when vips didn't. The basis for this feature relies on libtiff, so I guess updating libtiff to latest version would supposedly solve the problem.

https://github.com/libvips/libvips/issues/1839

Regards

joesong168 avatar Apr 20 '22 14:04 joesong168

It's possible the prebuilt libvips binaries provided for Windows already supports this according to https://github.com/libvips/build-win64-mxe/blob/8f930b90e7a02b279ae2b8b9093ff7128a418726/build/overrides.mk#L228

The script to build the Linux and macOS binaries would need the addition of --with-webp-include-dir and --with-webp-lib-dir flags approximately here - https://github.com/lovell/sharp-libvips/blob/e44951ab0043efc525cc60eeab2efaf4e4dab35e/build/lin.sh#L328

We'd also need to modify the following to allow webp as a possible value:

https://github.com/lovell/sharp/blob/d396a4e65d5ed744dc4300c89ee1809fd7188638/lib/output.js#L770

Happy to accept PRs for these, probably starting with the scripts that build libvips binaries, if you're able.

lovell avatar Apr 20 '22 15:04 lovell

I can confirm that this already works on Windows, tested with:

vips copy zebra.jpg x.tif[compression=webp,pyramid]

Perhaps the packbits compression should also be allowed? The prebuilt binaries should already include support for this.

We could also add zstd and jp2k to that list for users who have built sharp with a globally installed libvips with support for those TIFF compression options (using libzstd and OpenJPEG).

kleisauke avatar Apr 20 '22 15:04 kleisauke

v0.31.0 now available with this improvement, thank you for the suggestion.

lovell avatar Sep 05 '22 09:09 lovell