ext/writer.c in ruby-vips-0.3.5 vs ext/writer.c in ruby-vips-0.3.6
- old
+ new
@@ -54,11 +54,11 @@
static VALUE
writer_meta_remove(VALUE obj, const char* name)
{
GetImg(obj, data, im);
-#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 22
+#if ATLEAST_VIPS( 7, 22 )
if (im_meta_remove(im, name))
return Qfalse;
#else
rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
@@ -145,12 +145,27 @@
char *buf = NULL;
int length;
GetImg(obj, data, im);
+#if ATLEAST_VIPS( 7, 28 )
+{
+ size_t len;
+
+ if (vips_jpegsave_buffer(im, &buf, &len,
+ "Q", NUM2INT(quality),
+ NULL))
+ vips_lib_error();
+
+ /* Argh.
+ */
+ length = len;
+}
+#else
if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length))
vips_lib_error();
+#endif
return rb_tainted_str_new(buf, length);
}
/* :nodoc: */
@@ -195,22 +210,28 @@
/* :nodoc: */
static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
-#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
char *buf;
size_t length;
GetImg(obj, data, im);
+#if ATLEAST_VIPS( 7, 28 )
+ if (vips_pngsave_buffer(im, &buf, &length,
+ "compression", NUM2INT(compression),
+ "interlace", NUM2INT(interlace),
+ NULL))
+ vips_lib_error();
+#elif ATLEAST_VIPS( 7, 23 )
if (im_vips2bufpng(im, NULL, NUM2INT(compression), NUM2INT(interlace),
&buf, &length))
vips_lib_error();
-
- return rb_tainted_str_new(buf, length);
#else
rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
+
+ return rb_tainted_str_new(buf, length);
}
/* :nodoc: */
static VALUE