class Vips::Source
A source. For example:
“‘ruby source = Vips::Source.new_from_file
(“k2.jpg”) image = Vips::Image.new_from_source(source)
“`
Public Class Methods
Create a new source from a file descriptor. File descriptors are small integers, for example 0 is stdin.
Pass sources to {Image.new_from_source} to load images from them.
@param descriptor [Integer] the file descriptor @return [Source] the new Vips::Source
# File lib/vips/source.rb, line 48 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
Create a new source from a file name.
Pass sources to {Image.new_from_source} to load images from them.
@param filename [String] the name of the file @return [Source] the new Vips::Source
# File lib/vips/source.rb, line 62 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
Create a new source from an area of memory. Memory areas can be strings, arrays and so forth – anything that supports bytesize.
Pass sources to {Image.new_from_source} to load images from them.
@param data [String] memory area @return [Source] the new Vips::Source
# File lib/vips/source.rb, line 78 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