Skip to content

Commit

Permalink
Refine GifExportParams (#417)
Browse files Browse the repository at this point in the history
* Refine GifExportParams

* Change gifDither range back to 0~10

* Add StripMetadata back

* Add StripMetadata back
  • Loading branch information
n0vad3v authored Mar 28, 2024
1 parent 0d1504b commit d2d2a1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vips/foreign.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ int set_tiffsave_options(VipsOperation *operation, SaveParams *params) {

// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-magicksave-buffer
int set_magicksave_options(VipsOperation *operation, SaveParams *params) {
int ret = vips_object_set(VIPS_OBJECT(operation), "format", "GIF", NULL);
int ret = vips_object_set(VIPS_OBJECT(operation), "format", "GIF", "bitdepth", params->gifBitdepth, NULL);

if (!ret && params->quality) {
ret = vips_object_set(VIPS_OBJECT(operation), "quality", params->quality,
NULL);
Expand All @@ -331,7 +332,7 @@ int set_magicksave_options(VipsOperation *operation, SaveParams *params) {
int set_gifsave_options(VipsOperation *operation, SaveParams *params) {
int ret = 0;
// See for argument values: https://www.libvips.org/API/current/VipsForeignSave.html#vips-gifsave
if (params->gifDither > 0.0 && params->gifDither <= 1.0) {
if (params->gifDither > 0.0 && params->gifDither <= 10) {
ret = vips_object_set(VIPS_OBJECT(operation), "dither", params->gifDither, NULL);
}
if (params->gifEffort >= 1 && params->gifEffort <= 10) {
Expand Down
4 changes: 4 additions & 0 deletions vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ func NewTiffExportParams() *TiffExportParams {
}
}

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

0 comments on commit d2d2a1f

Please sign in to comment.