mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Set PNG bitdepth based on number of colours #2855
Removes use of deprecated libvips API
This commit is contained in:
@@ -405,7 +405,7 @@ function png (options) {
|
||||
const colours = options.colours || options.colors;
|
||||
if (is.defined(colours)) {
|
||||
if (is.integer(colours) && is.inRange(colours, 2, 256)) {
|
||||
this.options.pngColours = colours;
|
||||
this.options.pngBitdepth = 1 << 31 - Math.clz32(Math.ceil(Math.log2(colours)));
|
||||
} else {
|
||||
throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user