Browse Source

Save GIF with vips_gifsave_buffer

DarthSim 3 years ago
parent
commit
9d2ba808ed
3 changed files with 12 additions and 2 deletions
  1. 2 0
      CHANGELOG.md
  2. 9 1
      vips/vips.c
  3. 1 1
      vips/vips.go

+ 2 - 0
CHANGELOG.md

@@ -1,6 +1,8 @@
 # Changelog
 # Changelog
 
 
 ## [Unreleased]
 ## [Unreleased]
+### Change
+- Save GIFs without ImageMagick (vips 8.12+ required).
 
 
 ## [3.0.0.beta2] - 2021-11-15
 ## [3.0.0.beta2] - 2021-11-15
 ### Added
 ### Added

+ 9 - 1
vips/vips.c

@@ -15,6 +15,9 @@
 #define VIPS_SUPPORT_PNG_BITDEPTH \
 #define VIPS_SUPPORT_PNG_BITDEPTH \
   (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 10))
   (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 10))
 
 
+#define VIPS_SUPPORT_GIFSAVE \
+  (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 12))
+
 int
 int
 vips_initialize() {
 vips_initialize() {
   return vips_init("imgproxy");
   return vips_init("imgproxy");
@@ -617,7 +620,12 @@ vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
 
 
 int
 int
 vips_gifsave_go(VipsImage *in, void **buf, size_t *len) {
 vips_gifsave_go(VipsImage *in, void **buf, size_t *len) {
-  return vips_magicksave_buffer(in, buf, len, "format", "gif", NULL);
+#if VIPS_SUPPORT_GIFSAVE
+  return vips_gifsave_buffer(in, buf, len, NULL);
+#else
+  vips_error("vips_gifsave_go", "Saving GIF is not supported (libvips 8.12+ reuired)");
+  return 1;
+#endif
 }
 }
 
 
 int
 int

+ 1 - 1
vips/vips.go

@@ -169,7 +169,7 @@ func SupportsSave(it imagetype.Type) bool {
 	case imagetype.WEBP:
 	case imagetype.WEBP:
 		sup = hasOperation("webpsave_buffer")
 		sup = hasOperation("webpsave_buffer")
 	case imagetype.GIF:
 	case imagetype.GIF:
-		sup = hasOperation("magicksave_buffer")
+		sup = hasOperation("gifsave_buffer")
 	case imagetype.AVIF:
 	case imagetype.AVIF:
 		sup = hasOperation("heifsave_buffer")
 		sup = hasOperation("heifsave_buffer")
 	case imagetype.BMP:
 	case imagetype.BMP: