ext/writer.c in ruby-vips-0.2.1 vs ext/writer.c in ruby-vips-0.3.0

- old
+ new

@@ -1,8 +1,6 @@ #include "ruby_vips.h" -#include "image.h" -#include "header.h" /* :nodoc: */ static VALUE writer_initialize(int argc, VALUE *argv, VALUE obj) @@ -142,29 +140,19 @@ /* :nodoc: */ static VALUE jpeg_buf_internal(VALUE obj, VALUE quality) { - VipsImage *im_out; char *buf = NULL; int length; - VALUE str; GetImg(obj, data, im); - if (!(im_out = im_open("writer_jpeg_buf", "p"))) + if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length)) vips_lib_error(); - if (im_vips2bufjpeg(im, im_out, NUM2INT(quality), &buf, &length)) { - im_close(im_out); - vips_lib_error(); - } - - str = rb_tainted_str_new(buf, length); - im_close(im_out); - - return str; + return rb_tainted_str_new(buf, length); } /* :nodoc: */ static VALUE @@ -208,26 +196,18 @@ static VALUE png_buf_internal(VALUE obj, VALUE compression, VALUE interlace) { #if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23 - VipsImage *im_out; char *buf; size_t length; GetImg(obj, data, im); - if (!(im_out = im_open("writer_png_buf", "p"))) + if (im_vips2bufpng(im, NULL, NUM2INT(compression), NUM2INT(interlace), + &buf, &length)) vips_lib_error(); - if (im_vips2bufpng(im, im_out, NUM2INT(compression), NUM2INT(interlace), - &buf, &length)) { - im_close(im_out); - vips_lib_error(); - } - - im_close(im_out); - return rb_tainted_str_new(buf, length); #else rb_raise(eVIPSError, "This method is not implemented in your version of VIPS"); #endif } @@ -280,10 +260,10 @@ /* * Base class for image format readers. */ void -init_Writer() +init_Writer(void) { VALUE writer = rb_define_class_under(mVIPS, "Writer", rb_cObject); rb_include_module(writer, mVIPSHeader); rb_define_alloc_func(writer, img_init_partial_anyclass);