cgifsave: limit max number of colours to 255 (#2863)

* cgifsave: limit max number of colours to 255

* switch to VIPS_MIN
This commit is contained in:
Daniel Löbl 2022-06-19 13:16:03 +02:00 committed by GitHub
parent 41da0d28e0
commit 905a6fe79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -738,7 +738,11 @@ vips_foreign_save_cgif_build( VipsObject *object )
/* Set up libimagequant.
*/
cgif->attr = vips__quantise_attr_create();
vips__quantise_set_max_colors( cgif->attr, 1 << cgif->bitdepth );
/* Limit the number of colours to 255, so there is always one index
* free for the transparency optimization.
*/
vips__quantise_set_max_colors( cgif->attr,
VIPS_MIN( 255, 1 << cgif->bitdepth ) );
vips__quantise_set_quality( cgif->attr, 0, 100 );
vips__quantise_set_speed( cgif->attr, 11 - cgif->effort );