diff --git a/lib/vips/image.rb b/lib/vips/image.rb index 8d35433..be85807 100644 --- a/lib/vips/image.rb +++ b/lib/vips/image.rb @@ -458,14 +458,14 @@ def self.new_from_source source, option_string, **opts loader = Vips.vips_foreign_find_load_source source raise Vips::Error if loader.nil? - image = Vips::Operation.call loader, [source], opts, option_string + result = Vips::Operation.call loader, [source], opts, option_string # keep a secret ref to the source object ... the libvips loader will # keep a ref to the C source object, but we need the ruby wrapper object # to stay alive too - image.references << source + result.references << source if result.is_a?(Vips::Image) - image + result end def self.matrix_from_array width, height, array