-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
Description
Describe the bug
The documentation states that Vips::Image.new_from_memory
should accept a FFI::Pointer
as data argument, but a FFI::Pointer
does not meet the requested interface because it's missing a bytesize
method, which a String
does have.
This also affects Vips::Image.new_from_memory_copy
Link to documentation: https://www.rubydoc.info/gems/ruby-vips/Vips%2FImage.new_from_memory
The incompatibility seems to have been introduced with this commit: a7eef4c
To Reproduce
ptr = FFI::MemoryPointer.new(:uchar, 10*10*3)
=> #<FFI::MemoryPointer address=0x00007fc2317b3ed0 size=300>
Vips::Image.new_from_memory(ptr, 10, 10, 3, :uchar)
=> Traceback (most recent call last):
3: from bin/console:14:in `<main>'
2: from (irb):16
1: from /ruby/2.7.2/lib/ruby/gems/2.7.0/gems/ruby-vips-2.1.0/lib/vips/image.rb:343:in `new_from_memory'
NoMethodError (undefined method `bytesize' for #<FFI::MemoryPointer address=0x00007fc2317b3ed0 size=300>)
Did you mean? type_size
Expected behavior
It is expected to load a Vips::Image
from a String
or FFI::Pointer
.