class Vips::Source

“‘
image = Vips::Image.new_from_source(source)
source = Vips::Source.new_from_file(“k2.jpg”)
“`ruby
A source. For example:

def self.new_from_descriptor(descriptor)

Returns:
  • (Source) - the new Vips::Source

Parameters:
  • descriptor (Integer) -- the file descriptor
def self.new_from_descriptor(descriptor)
  ptr = Vips.vips_source_new_from_descriptor descriptor
  raise Vips::Error if ptr.null?
  Vips::Source.new ptr
end

def self.new_from_file(filename)

Returns:
  • (Source) - the new Vips::Source

Parameters:
  • filename (String) -- the name of the file
def self.new_from_file(filename)
  raise Vips::Error, "filename is nil" if filename.nil?
  ptr = Vips.vips_source_new_from_file filename
  raise Vips::Error if ptr.null?
  Vips::Source.new ptr
end

def self.new_from_memory(data)

Returns:
  • (Source) - the new Vips::Source

Parameters:
  • data (String) -- memory area
def self.new_from_memory(data)
  ptr = Vips.vips_source_new_from_memory data, data.bytesize
  raise Vips::Error if ptr.null?
  # FIXME do we need to keep a ref to the underlying memory area? what
  # about Image.new_from_buffer? Does that need a secret ref too?
  Vips::Source.new ptr
end