@@ -327,6 +327,22 @@ int set_magicksave_options(VipsOperation *operation, SaveParams *params) {
327
327
return ret ;
328
328
}
329
329
330
+ // https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-gifsave-buffer
331
+ int set_gifsave_options (VipsOperation * operation , SaveParams * params ) {
332
+ int ret = 0 ;
333
+ // See for argument values: https://www.libvips.org/API/current/VipsForeignSave.html#vips-gifsave
334
+ if (params -> gifDither > 0.0 && params -> gifDither <= 1.0 ) {
335
+ ret = vips_object_set (VIPS_OBJECT (operation ), "dither" , params -> gifDither , NULL );
336
+ }
337
+ if (params -> gifEffort >= 1 && params -> gifEffort <= 10 ) {
338
+ ret = vips_object_set (VIPS_OBJECT (operation ), "effort" , params -> gifEffort , NULL );
339
+ }
340
+ if (params -> gifBitdepth >= 1 && params -> gifBitdepth <= 8 ) {
341
+ ret = vips_object_set (VIPS_OBJECT (operation ), "bitdepth" , params -> gifBitdepth , NULL );
342
+ }
343
+ return ret ;
344
+ }
345
+
330
346
int set_avifsave_options (VipsOperation * operation , SaveParams * params ) {
331
347
int ret = vips_object_set (
332
348
VIPS_OBJECT (operation ), "compression" , VIPS_FOREIGN_HEIF_COMPRESSION_AV1 ,
@@ -406,7 +422,11 @@ int save_to_buffer(SaveParams *params) {
406
422
case TIFF :
407
423
return save_buffer ("tiffsave_buffer" , params , set_tiffsave_options );
408
424
case GIF :
425
+ #if (VIPS_MAJOR_VERSION >= 8 ) && (VIPS_MINOR_VERSION >= 12 )
426
+ return save_buffer ("gifsave_buffer" , params , set_gifsave_options );
427
+ #else
409
428
return save_buffer ("magicksave_buffer" , params , set_magicksave_options );
429
+ #endif
410
430
case AVIF :
411
431
return save_buffer ("heifsave_buffer" , params , set_avifsave_options );
412
432
case JP2K :
@@ -460,6 +480,10 @@ static SaveParams defaultSaveParams = {
460
480
.pngDither = 0 ,
461
481
.pngFilter = VIPS_FOREIGN_PNG_FILTER_NONE ,
462
482
483
+ .gifDither = 0.0 ,
484
+ .gifEffort = 0 ,
485
+ .gifBitdepth = 0 ,
486
+
463
487
.webpLossless = FALSE,
464
488
.webpNearLossless = FALSE,
465
489
.webpReductionEffort = 4 ,
0 commit comments