lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.27k stars 1.3k forks source link

Enhancement: expose pngsave options requiring libimagequant #1484

Closed lovell closed 5 years ago

lovell commented 5 years ago

https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-pngsave

/*
 * @param {Boolean} [options.palette=false] - quantise to a palette-based image with alpha transparency support, requires libimagequant
 * @param {Number} [options.quality=100] - use the lowest number of colours needed to achieve given quality, requires libimagequant
 * @param {Number} [options.colours=256] - maximum number of palette entries, requires libimagequant
 * @param {Number} [options.colors=256] - alternative spelling of `options.colours`, requires libimagequant
 * @param {Number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, requires libimagequant
/

Please note that the pre-compiled binaries provided by sharp will not include libimagequant. If you require these possible future options then libvips will have to be compiled from source and globally installed.

jaubourg commented 5 years ago

@lovell any plan to have libimagequant included in libvips/sharp by default in the near future?

lovell commented 5 years ago

libimagequant is GPL so you'll have to roll your own.

avishnyak commented 5 years ago

For anyone looking for a precompiled version of this. I will try to maintain one that can be used just by setting an environment variable before doing an npm/yarn install.

Set ENV Variable SHARP_DIST_BASE_URL=https://github.com/avishnyak/sharp-libvips/releases/download/v8.7.4 (or newer version when they are released).

NOTE: This includes libimagequant which is GPL code and I'm only compiling for linux-x64 right now.

Other linux targets are probably simple to add if someone needs it (just open an issue).

felixbuenemann commented 5 years ago

@lovell If licensing is a problem you could ask @kornelski about cross-licensing libimagequant to eg. LGPL or an exception for binary distribution in sharp.

Another solution could be to vendor https://github.com/exoticorn/exoquant in libvips and use it as a (slower) fallback, if libimagequant is missing. It would make the quality parameter useless though.

ArunJRK commented 3 years ago

For anyone looking for a precompiled version of this. I will try to maintain one that can be used just by setting an environment variable before doing an npm/yarn install.

Set ENV Variable SHARP_DIST_BASE_URL=https://github.com/avishnyak/sharp-libvips/releases/download/v8.7.4 (or newer version when they are released).

NOTE: This includes libimagequant which is GPL code and I'm only compiling for linux-x64 right now.

Other linux targets are probably simple to add if someone needs it (just open an issue).

Thank you so much 😀😁❤