Skip to content

cgifsave: limit max number of colours to 255 #2863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libvips/foreign/cgifsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,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 );

Expand Down