Closed thomas07vt closed 3 years ago
So I added some debugging above the line that fails for image_processing:
#lib/image_processing/vips.rb:145
puts "width: #{width.inspect} | height: #{height.inspect} | options: #{options.inspect}"
image = self.image.thumbnail_image(width, height: height, **options)
which results in:
width: "100" | height: "100" | options: {:no_rotate=>true, :size=>:down}
So the width and height are being passed in as strings, which seems like it might be causing the issue?
Additionally, I added some debugging logs in ruby-vips
#lib/vips/gvalue.rb:99
when GINT_TYPE
puts "VALUE: #{value.inspect} | #{value.class}"
puts self.inspect
::GObject.g_value_set_int self, value
which results in
VALUE: "100" | String
#<GObject::GValue:0x000056170d218890>
I just tested casting the value to an integer and it does work:
::GObject.g_value_set_int self, value.to_i
I am not sure if this is a bug in https://github.com/libvips/ruby-vips or https://github.com/janko/image_processing.
cc @janko @jcupitt
ps. thanks for image_processing and ruby-vips!
I guess an easy fix would be to call file.variant(resize_to_limit: [100, 100]).processed
and not use strings :)
Yes, the imagemagick backend builds a command-line for you and executes convert
in a subshell, so strings for numbers are fine. Though actual numbers work too.
The ruby-vips backend makes direct calls into a native library, so it needs numbers as ints.
tldr: don't use strings for numbers, as you say
I am going to go ahead and close this issue, but just an fyi, I know strings worked for image_processing (1.10.0)
and ruby-vips (2.0.16)
Versions
ruby 3.0.1p64 ruby-vips 2.1.2 image_processing 1.12.1
Issue
I seem to be having the same issue as this: https://github.com/libvips/ruby-vips/issues/303
When I try to create a variant on a .heic file:
file.variant(resize_to_limit: ["100", "100"]).processed
I get this error:
TypeError: no implicit conversion of String into Integer
I don't believe it has to do with libvips recognizing the heic file because I can take the exact same file and convert it to a PNG:
io = ImageProcessing::Vips.source(blob).convert("png").call
Here is the truncated backtrace:
Reproducibility Info
In case you want to reproduce, this is the heic previewer I am using:
and this is in an initializer file: