class Vips::SourceCustom

to read from a named file)
(just an example – of course in practice you’d use {Source#new_from_file}
“‘
image = Vips::Image.new_from_source source
source.on_read { |length| file.read length }
source = Vips::SourceCustom.new
file = File.open “some/file/name”, “rb”
“`ruby
For example:
custom input types.
A source you can attach action signal handlers to to implement

def initialize

def initialize
  pointer = Vips.vips_source_custom_new
  raise Vips::Error if pointer.null?
  super(pointer)
end

def on_read &block

Other tags:
    Yieldreturn: - Up to length bytes of data, or nil for EOF

Other tags:
    Yieldparam: length - Read and return up to this many bytes
def on_read &block
  signal_connect "read" do |buf, len|
    chunk = block.call len
    return 0 if chunk.nil?
    bytes_read = chunk.bytesize
    buf.put_bytes(0, chunk, 0, bytes_read)
    chunk.clear
    bytes_read
  end
end

def on_seek &block

Other tags:
    Yieldreturn: - the new read position, or -1 on error

Other tags:
    Yieldparam: whence - Seek whence
    Yieldparam: offset - Seek offset
def on_seek &block
  signal_connect "seek" do |offset, whence|
    block.call offset, whence
  end
end