Skip to content

Commit d2d2a1f

Browse files
authored
Refine GifExportParams (#417)
* Refine GifExportParams * Change gifDither range back to 0~10 * Add StripMetadata back * Add StripMetadata back
1 parent 0d1504b commit d2d2a1f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

vips/foreign.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ int set_tiffsave_options(VipsOperation *operation, SaveParams *params) {
319319

320320
// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-magicksave-buffer
321321
int set_magicksave_options(VipsOperation *operation, SaveParams *params) {
322-
int ret = vips_object_set(VIPS_OBJECT(operation), "format", "GIF", NULL);
322+
int ret = vips_object_set(VIPS_OBJECT(operation), "format", "GIF", "bitdepth", params->gifBitdepth, NULL);
323+
323324
if (!ret && params->quality) {
324325
ret = vips_object_set(VIPS_OBJECT(operation), "quality", params->quality,
325326
NULL);
@@ -331,7 +332,7 @@ int set_magicksave_options(VipsOperation *operation, SaveParams *params) {
331332
int set_gifsave_options(VipsOperation *operation, SaveParams *params) {
332333
int ret = 0;
333334
// 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+
if (params->gifDither > 0.0 && params->gifDither <= 10) {
335336
ret = vips_object_set(VIPS_OBJECT(operation), "dither", params->gifDither, NULL);
336337
}
337338
if (params->gifEffort >= 1 && params->gifEffort <= 10) {

vips/image.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ func NewTiffExportParams() *TiffExportParams {
314314
}
315315
}
316316

317+
// GifExportParams are options when exporting a GIF to file or buffer
318+
// Please note that if vips version is above 8.12, then `vips_gifsave_buffer` is used, and only `Dither`, `Effort`, `Bitdepth` is used.
319+
// If vips version is below 8.12, then `vips_magicksave_buffer` is used, and only `Bitdepth`, `Quality` is used.
320+
// StripMetadata does nothing to Gif images.
317321
type GifExportParams struct {
318322
StripMetadata bool
319323
Quality int

0 commit comments

Comments
 (0)