Class: Vips::Image

Inherits:
Object show all
Defined in:
lib/vips/image.rb,
lib/vips/methods.rb

Overview

This class represents a libvips image. See the Vips module documentation for an introduction to using this class.

Defined Under Namespace

Modules: ImageLayout Classes: GenericPtr, ManagedStruct, Struct

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#get_pspec, #get_typeof_error, print_all

Methods inherited from GObject::GObject

#ffi_managed_struct, ffi_managed_struct, #ffi_struct, ffi_struct, #initialize

Constructor Details

This class inherits a constructor from GObject::GObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **options) ⇒ Object

Invoke a vips operation with Operation.call, using self as the first input argument.



209
210
211
# File 'lib/vips/image.rb', line 209

def method_missing name, *args, **options
    Vips::Operation.call name.to_s, [self, *args], options
end

Class Method Details

.analyzeload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load an analyze6 image.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 900

.arrayjoin(im, opts = {}) ⇒ Vips::Image

Join an array of images.

Options Hash (opts):

  • :across (Integer)

    Number of images across grid

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :halign (Vips::Align)

    Align on the left, centre or right

  • :valign (Vips::Align)

    Align on the top, centre or bottom

  • :hspacing (Integer)

    Horizontal spacing between images

  • :vspacing (Integer)

    Vertical spacing between images



# File 'lib/vips/methods.rb', line 362

.bandrank(im, opts = {}) ⇒ Vips::Image

Band-wise rank of a set of images.

Options Hash (opts):

  • :index (Integer)

    Select this band element from sorted list



# File 'lib/vips/methods.rb', line 414

.black(width, height, opts = {}) ⇒ Vips::Image

Make a black image.

Options Hash (opts):

  • :bands (Integer)

    Number of bands in image



# File 'lib/vips/methods.rb', line 562

.csvload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load csv from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :skip (Integer)

    Skip this many lines at the start of the file

  • :lines (Integer)

    Read this many lines from the file

  • :fail (Boolean)

    Fail on first error

  • :whitespace (String)

    Set of whitespace characters

  • :separator (String)

    Set of separator characters

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 852

.eye(width, height, opts = {}) ⇒ Vips::Image

Make an image showing the eye's spatial response.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :factor (Float)

    Maximum spatial frequency



# File 'lib/vips/methods.rb', line 620

.fitsload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load a fits image.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1159

.fractsurf(width, height, fractal_dimension, opts = {}) ⇒ Vips::Image

Make a fractal surface.



# File 'lib/vips/methods.rb', line 827

.gaussmat(sigma, min_ampl, opts = {}) ⇒ Vips::Image

Make a gaussian image.

Options Hash (opts):

  • :separable (Boolean)

    Generate separable Gaussian

  • :precision (Vips::Precision)

    Generate with this precision



# File 'lib/vips/methods.rb', line 602

.gaussnoise(width, height, opts = {}) ⇒ Vips::Image

Make a gaussnoise image.

Options Hash (opts):

  • :sigma (Float)

    Standard deviation of pixels in generated image

  • :mean (Float)

    Mean of pixels in generated image



# File 'lib/vips/methods.rb', line 570

.gifload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load gif with giflib.

Options Hash (opts):

  • :n (Integer)

    Load this many pages

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 994

.gifload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load gif with giflib.

Options Hash (opts):

  • :n (Integer)

    Load this many pages

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1006

.grey(width, height, opts = {}) ⇒ Vips::Image

Make a grey ramp image.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image



# File 'lib/vips/methods.rb', line 629

.identity(opts = {}) ⇒ Vips::Image

Make a 1d image where pixel values are indexes.

Options Hash (opts):

  • :bands (Integer)

    Number of bands in LUT

  • :ushort (Boolean)

    Create a 16-bit LUT

  • :size (Integer)

    Size of 16-bit LUT



# File 'lib/vips/methods.rb', line 819

.jpegload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first error

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1048

.jpegload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg from buffer.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first error

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1060

.logmat(sigma, min_ampl, opts = {}) ⇒ Vips::Image

Make a laplacian of gaussian image.

Options Hash (opts):

  • :separable (Boolean)

    Generate separable Logmatian

  • :precision (Vips::Precision)

    Generate with this precision



# File 'lib/vips/methods.rb', line 611

.magickload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load file with imagemagick.

Options Hash (opts):

  • :density (String)

    Canvas resolution for rendering vector formats like SVG

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1133

.magickload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load buffer with imagemagick.

Options Hash (opts):

  • :density (String)

    Canvas resolution for rendering vector formats like SVG

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1146

.mask_butterworth(width, height, order, frequency_cutoff, amplitude_cutoff, opts = {}) ⇒ Vips::Image

Make a butterworth filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 694

.mask_butterworth_band(width, height, order, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, opts = {}) ⇒ Vips::Image

Make a butterworth_band filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 723

.mask_butterworth_ring(width, height, order, frequency_cutoff, amplitude_cutoff, ringwidth, opts = {}) ⇒ Vips::Image

Make a butterworth ring filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 708

.mask_fractal(width, height, fractal_dimension, opts = {}) ⇒ Vips::Image

Make fractal filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 781

.mask_gaussian(width, height, frequency_cutoff, amplitude_cutoff, opts = {}) ⇒ Vips::Image

Make a gaussian filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 739

.mask_gaussian_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, opts = {}) ⇒ Vips::Image

Make a gaussian filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 766

.mask_gaussian_ring(width, height, frequency_cutoff, amplitude_cutoff, ringwidth, opts = {}) ⇒ Vips::Image

Make a gaussian ring filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 752

.mask_ideal(width, height, frequency_cutoff, opts = {}) ⇒ Vips::Image

Make an ideal filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 655

.mask_ideal_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, opts = {}) ⇒ Vips::Image

Make an ideal band filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 680

.mask_ideal_ring(width, height, frequency_cutoff, ringwidth, opts = {}) ⇒ Vips::Image

Make an ideal ring filter.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



# File 'lib/vips/methods.rb', line 667

.matload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load mat from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1038

.matrix_from_array(width, height, array) ⇒ Object



305
306
307
308
309
310
311
# File 'lib/vips/image.rb', line 305

def self.matrix_from_array width, height, array
    ptr = FFI::MemoryPointer.new :double, array.length
    ptr.write_array_of_double array
    image = Vips::vips_image_new_matrix_from_array width, height, 
        ptr, array.length
    Vips::Image.new image
end

.matrixload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load matrix from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 866

.method_missing(name, *args, **options) ⇒ Object

Invoke a vips operation with Operation.call.



214
215
216
# File 'lib/vips/image.rb', line 214

def self.method_missing name, *args, **options
    Vips::Operation.call name.to_s, args, options
end

.new_from_array(array, scale = 1, offset = 0) ⇒ Image

Create a new Image from a 1D or 2D array. A 1D array becomes an image with height 1. Use scale and offset to set the scale and offset fields in the header. These are useful for integer convolutions.

For example:

image = Vips::new_from_array [1, 2, 3]

or

image = Vips::new_from_array [
    [-1, -1, -1],
    [-1, 16, -1],
    [-1, -1, -1]], 8

for a simple sharpening mask.

Raises:



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/vips/image.rb', line 339

def self.new_from_array array, scale = 1, offset = 0
    # we accept a 1D array and assume height == 1, or a 2D array
    # and check all lines are the same length
    unless array.is_a? Array
        raise Vips::Error, "Argument is not an array."
    end

    if array[0].is_a? Array
        height = array.length
        width = array[0].length
        unless array.all? {|x| x.is_a? Array}
            raise Vips::Error, "Not a 2D array."
        end
        unless array.all? {|x| x.length == width}
            raise Vips::Error, "Array not rectangular."
        end
        array = array.flatten
    else
        height = 1
        width = array.length
    end

    unless array.all? {|x| x.is_a? Numeric}
        raise Vips::Error, "Not all array elements are Numeric."
    end

    image = Vips::Image.matrix_from_array width, height, array
    raise Vips::Error if image == nil

    # be careful to set them as double
    image.set_type GObject::GDOUBLE_TYPE, 'scale', scale.to_f
    image.set_type GObject::GDOUBLE_TYPE, 'offset', offset.to_f

    return image
end

.new_from_buffer(data, option_string, opts = {}) ⇒ Image

Create a new Vips::Image for an image encoded, in a format such as JPEG, in a memory string. Load options may be passed as strings or appended as a hash. For example:

image = Vips::Image.new_from_buffer memory_buffer, "shrink=2"

or alternatively:

image = Vips::Image.new_from_buffer memory_buffer, "", shrink: 2

The options available depend on the file format. Try something like:

$ vips jpegload_buffer

at the command-line to see the available options. Not all loaders support load from buffer, but at least JPEG, PNG and TIFF images will work.

Loading is fast: only enough of the image is loaded to be able to fill out the header. Pixels will only be decompressed when they are needed.

Options Hash (opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

  • :access (Vips::Access) — default: :random

    Access mode for file

Raises:



298
299
300
301
302
303
# File 'lib/vips/image.rb', line 298

def self.new_from_buffer data, option_string, opts = {}
    loader = Vips::vips_foreign_find_load_buffer data, data.bytesize
    raise Vips::Error if loader == nil

    Vips::Operation.call loader, [data], opts, option_string
end

.new_from_file(name, opts = {}) ⇒ Image

Return a new Vips::Image for a file on disc. This method can load images in any format supported by vips. The filename can include load options, for example:

image = Vips::new_from_file "fred.jpg[shrink=2]"

You can also supply options as a hash, for example:

image = Vips::new_from_file "fred.jpg", shrink: 2

The full set of options available depend upon the load operation that will be executed. Try something like:

$ vips jpegload

at the command-line to see a summary of the available options for the JPEG loader.

Loading is fast: only enough of the image is loaded to be able to fill out the header. Pixels will only be decompressed when they are needed.

Options Hash (opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

  • :access (Vips::Access) — default: :random

    Access mode for file

Raises:



254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/vips/image.rb', line 254

def self.new_from_file name, opts = {}
    # very common, and Vips::vips_filename_get_filename will segv if we 
    # pass this
    raise Vips::Error, "filename is nil" if name == nil

    filename = Vips::p2str(Vips::vips_filename_get_filename name)
    option_string = Vips::p2str(Vips::vips_filename_get_options name)
    loader = Vips::vips_foreign_find_load filename
    raise Vips::Error if loader == nil

    Operation.call loader, [filename], opts, option_string
end

.openexrload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load an openexr image.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1169

.openslideload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load file with openslide.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :level (Integer)

    Load this level from the file

  • :autocrop (Boolean)

    Crop to image bounds

  • :fail (Boolean)

    Fail on first error

  • :associated (String)

    Load this associated image

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1120

.pdfload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load pdf with libpoppler.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :fail (Boolean)

    Fail on first error

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 930

.pdfload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load pdf with libpoppler.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :fail (Boolean)

    Fail on first error

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 944

.perlin(width, height, opts = {}) ⇒ Vips::Image

Make a perlin noise image.

Options Hash (opts):

  • :cell_size (Integer)

    Size of Perlin cells

  • :uchar (Boolean)

    Output an unsigned char image



# File 'lib/vips/methods.rb', line 843

.pngload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load png from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1018

.pngload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load png from buffer.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1028

.ppmload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load ppm from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 910

.radload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load a radiance image from a file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 920

.rawload(filename, width, height, bands, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load raw data from a file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :offset (guint64)

    Offset in bytes from start of file

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 876

.respond_to?(name, include_all = false) ⇒ Boolean



197
198
199
200
201
202
# File 'lib/vips/image.rb', line 197

def self.respond_to? name, include_all = false
    # respond to all vips operations by nickname
    return true if Vips::type_find("VipsOperation", name.to_s) != 0

    super
end

.sines(width, height, opts = {}) ⇒ Vips::Image

Make a 2d sine wave.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :hfreq (Float)

    Horizontal spatial frequency

  • :vfreq (Float)

    Vertical spatial frequency



# File 'lib/vips/methods.rb', line 645

.sum(im, opts = {}) ⇒ Vips::Image

Sum an array of images.



# File 'lib/vips/methods.rb', line 79

.svgload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load svg with rsvg.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :dpi (Float)

    Render at this DPI

  • :fail (Boolean)

    Fail on first error

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 958

.svgload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load svg with rsvg.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :dpi (Float)

    Render at this DPI

  • :fail (Boolean)

    Fail on first error

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 982

.system(cmd_format, opts = {}) ⇒ nil, Hash<Symbol => Object>

Run an external command.

Options Hash (opts):

  • :im (Array<Image>)

    Array of input images

  • :out_format (String)

    Format for output filename

  • :in_format (String)

    Format for input filename

  • :out (Vips::Image)

    Output Output image

  • :log (String)

    Output Command log



# File 'lib/vips/methods.rb', line 4

.text(text, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Make a text image.

Options Hash (opts):

  • :font (String)

    Font to render with

  • :width (Integer)

    Maximum image width in pixels

  • :height (Integer)

    Maximum image height in pixels

  • :align (Vips::Align)

    Align on the low, centre or high edge

  • :dpi (Integer)

    DPI to render at

  • :spacing (Integer)

    Line spacing

  • :autofit_dpi (Integer)

    Output DPI selected by autofit



# File 'lib/vips/methods.rb', line 579

.thumbnail(filename, width, opts = {}) ⇒ Vips::Image

Generate thumbnail from file.

Options Hash (opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :auto_rotate (Boolean)

    Use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent



# File 'lib/vips/methods.rb', line 1462

.thumbnail_buffer(buffer, width, opts = {}) ⇒ Vips::Image

Generate thumbnail from buffer.

Options Hash (opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :auto_rotate (Boolean)

    Use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent



# File 'lib/vips/methods.rb', line 1477

.tiffload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load tiff from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the image

  • :n (Integer)

    Load this many pages

  • :fail (Boolean)

    Fail on first error

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1094

.tiffload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load tiff from buffer.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the image

  • :n (Integer)

    Load this many pages

  • :fail (Boolean)

    Fail on first error

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1107

.tonelut(opts = {}) ⇒ Vips::Image

Build a look-up table.

Options Hash (opts):

  • :in_max (Integer)

    Size of LUT to build

  • :out_max (Integer)

    Maximum value in output LUT

  • :Lb (Float)

    Lowest value in output

  • :Lw (Float)

    Highest value in output

  • :Ps (Float)

    Position of shadow

  • :Pm (Float)

    Position of mid-tones

  • :Ph (Float)

    Position of highlights

  • :S (Float)

    Adjust shadows by this much

  • :M (Float)

    Adjust mid-tones by this much

  • :H (Float)

    Adjust highlights by this much



# File 'lib/vips/methods.rb', line 804

.vipsload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load vips from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 890

.webpload(filename, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load webp from file.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1072

.webpload_buffer(buffer, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Load webp from buffer.

Options Hash (opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first error

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



# File 'lib/vips/methods.rb', line 1083

.worley(width, height, opts = {}) ⇒ Vips::Image

Make a worley noise image.

Options Hash (opts):

  • :cell_size (Integer)

    Size of Worley cells



# File 'lib/vips/methods.rb', line 835

.xyz(width, height, opts = {}) ⇒ Vips::Image

Make an image where pixel values are coordinates.

Options Hash (opts):

  • :csize (Integer)

    Size of third dimension

  • :dsize (Integer)

    Size of fourth dimension

  • :esize (Integer)

    Size of fifth dimension



# File 'lib/vips/methods.rb', line 592

.zone(width, height, opts = {}) ⇒ Vips::Image

Make a zone plate.

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image



# File 'lib/vips/methods.rb', line 637

Instance Method Details

#!Image

Equivalent to image ^ -1



855
856
857
# File 'lib/vips/image.rb', line 855

def !
    self ^ -1
end

#!=(other) ⇒ Image

Compare inequality to nil, an image, constant or array.



929
930
931
932
933
934
935
936
# File 'lib/vips/image.rb', line 929

def != other
    # for equality, we must allow tests against nil
    if other == nil
        true
    else
        call_enum "relational", other, :noteq
    end
end

#%(other) ⇒ Image

Remainder after integer division with an image, constant or array.



799
800
801
802
# File 'lib/vips/image.rb', line 799

def % other
    other.is_a?(Vips::Image) ? 
        remainder(other) : remainder_const(other)
end

#&(other) ⇒ Image

Integer bitwise AND with an image, constant or array.



840
841
842
# File 'lib/vips/image.rb', line 840

def & other
    call_enum "boolean", other, :and
end

#*(other) ⇒ Image

Multiply an image, constant or array.



781
782
783
784
# File 'lib/vips/image.rb', line 781

def * other
    other.is_a?(Vips::Image) ? 
        multiply(other) : linear(other, 0)
end

#**(other) ⇒ Image

Raise to power of an image, constant or array.



808
809
810
# File 'lib/vips/image.rb', line 808

def ** other
    call_enum "math2", other, :pow
end

#+(other) ⇒ Image

Add an image, constant or array.



763
764
765
766
# File 'lib/vips/image.rb', line 763

def + other 
    other.is_a?(Vips::Image) ? 
        add(other) : linear(1, other)
end

#+@Image



867
868
869
# File 'lib/vips/image.rb', line 867

def +@
    self
end

#-(other) ⇒ Image

Subtract an image, constant or array.



772
773
774
775
# File 'lib/vips/image.rb', line 772

def - other
    other.is_a?(Vips::Image) ? 
        subtract(other) : linear(1, Image::smap(other) {|x| x * -1})
end

#-@Image

Equivalent to image * -1



874
875
876
# File 'lib/vips/image.rb', line 874

def -@
    self * -1
end

#/(other) ⇒ Image

Divide an image, constant or array.



790
791
792
793
# File 'lib/vips/image.rb', line 790

def / other
    other.is_a?(Vips::Image) ? 
        divide(other) : linear(Image::smap(other) {|x| 1.0 / x}, 0)
end

#<(other) ⇒ Image

Relational less than with an image, constant or array.



882
883
884
# File 'lib/vips/image.rb', line 882

def < other
    call_enum "relational", other, :less
end

#<<(other) ⇒ Image

Integer left shift with an image, constant or array.



816
817
818
# File 'lib/vips/image.rb', line 816

def << other
    call_enum "boolean", other, :lshift
end

#<=(other) ⇒ Image

Relational less than or equal to with an image, constant or array.



891
892
893
# File 'lib/vips/image.rb', line 891

def <= other
    call_enum "relational", other, :lesseq
end

#==(other) ⇒ Image

Compare equality to nil, an image, constant or array.



916
917
918
919
920
921
922
923
# File 'lib/vips/image.rb', line 916

def == other
    # for equality, we must allow tests against nil
    if other == nil
        false
    else
        call_enum "relational", other, :equal
    end
end

#>(other) ⇒ Image

Relational more than with an image, constant or array.



899
900
901
# File 'lib/vips/image.rb', line 899

def > other
    call_enum "relational", other, :more
end

#>=(other) ⇒ Image

Relational more than or equal to with an image, constant or array.



908
909
910
# File 'lib/vips/image.rb', line 908

def >= other
    call_enum "relational", other, :moreeq
end

#>>(other) ⇒ Image

Integer right shift with an image, constant or array.



824
825
826
# File 'lib/vips/image.rb', line 824

def >> other
    call_enum "boolean", other, :rshift
end

#[](index) ⇒ Image

Fetch bands using a number or a range



942
943
944
945
946
947
948
949
950
951
# File 'lib/vips/image.rb', line 942

def [] index
    if index.is_a? Range
        n = index.size
        extract_band index.begin, n: n
    elsif index.is_a? Numeric
        extract_band index 
    else
        raise Vips::Error, "[] index is not range or numeric."
    end
end

#^(other) ⇒ Image

Integer bitwise EOR with an image, constant or array.



848
849
850
# File 'lib/vips/image.rb', line 848

def ^ other
    call_enum "boolean", other, :eor
end

#abs(opts = {}) ⇒ Vips::Image

Absolute value of an image.



# File 'lib/vips/methods.rb', line 104

#acosImage

Return the inverse cosine of an image in degrees.



1209
1210
1211
# File 'lib/vips/image.rb', line 1209

def acos
    math :acos
end

#add(right, opts = {}) ⇒ Vips::Image

Add two images.



# File 'lib/vips/methods.rb', line 15

#add_alphaImage

Append an alpha channel to an image.

Raises:



729
730
731
732
733
734
735
# File 'lib/vips/image.rb', line 729

def add_alpha
    ptr = GenericPtr.new
    result = Vips::vips_addalpha self, ptr
    raise Vips::Error if result != 0

    Vips::Image.new ptr[:value]
end

#affine(matrix, opts = {}) ⇒ Vips::Image

Affine transform of an image.

Options Hash (opts):

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :oarea (Array<Integer>)

    Area of output to generate

  • :odx (Float)

    Horizontal output displacement

  • :ody (Float)

    Vertical output displacement

  • :idx (Float)

    Horizontal input displacement

  • :idy (Float)

    Vertical input displacement

  • :background (Array<Double>)

    Background value

  • :extend (Vips::Extend)

    How to generate the extra pixels



# File 'lib/vips/methods.rb', line 1564

#asinImage

Return the inverse sine of an image in degrees.



1202
1203
1204
# File 'lib/vips/image.rb', line 1202

def asin
    math :asin
end

#atanImage

Return the inverse tangent of an image in degrees.



1216
1217
1218
# File 'lib/vips/image.rb', line 1216

def atan
    math :atan
end

#autorot(opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Autorotate image by exif tag.

Options Hash (opts):

  • :angle (Vips::Angle)

    Output Angle image was rotated by



# File 'lib/vips/methods.rb', line 458

#avg(opts = {}) ⇒ Float

Find image average.



# File 'lib/vips/methods.rb', line 159

#bandandImage

AND the bands of an image together



1011
1012
1013
# File 'lib/vips/image.rb', line 1011

def bandand
    bandbool :and
end

#bandbool(boolean, opts = {}) ⇒ Vips::Image

Boolean operation across image bands.



# File 'lib/vips/methods.rb', line 426

#bandeorImage

EOR the bands of an image together



1025
1026
1027
# File 'lib/vips/image.rb', line 1025

def bandeor
    bandbool :eor
end

#bandfold(opts = {}) ⇒ Vips::Image

Fold up x axis into bands.

Options Hash (opts):

  • :factor (Integer)

    Fold by this factor



# File 'lib/vips/methods.rb', line 470

#bandjoin(other) ⇒ Image

Join a set of images bandwise.



1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# File 'lib/vips/image.rb', line 1040

def bandjoin other
    unless other.is_a? Array
        other = [other]
    end

    # if other is just Numeric, we can use bandjoin_const
    not_all_real = !other.all?{|x| x.is_a? Numeric}

    if not_all_real
        Vips::Image.bandjoin([self] + other)
    else
        bandjoin_const other
    end
end

#bandjoin_const(c, opts = {}) ⇒ Vips::Image

Append a constant band to an image.



# File 'lib/vips/methods.rb', line 408

#bandmean(opts = {}) ⇒ Vips::Image

Band-wise average.



# File 'lib/vips/methods.rb', line 421

#bandorImage

OR the bands of an image together



1018
1019
1020
# File 'lib/vips/image.rb', line 1018

def bandor
    bandbool :or
end

#bandsInteger

Get number of image bands.



630
631
632
# File 'lib/vips/image.rb', line 630

def bands
    get "bands"
end

#bandsplitArray<Image>

Split an n-band image into n separate images.



1032
1033
1034
# File 'lib/vips/image.rb', line 1032

def bandsplit
    (0...bands).map {|i| extract_band i}
end

#bandunfold(opts = {}) ⇒ Vips::Image

Unfold image bands into x axis.

Options Hash (opts):

  • :factor (Integer)

    Unfold by this factor



# File 'lib/vips/methods.rb', line 476

#boolean(right, boolean, opts = {}) ⇒ Vips::Image

Boolean operation on two images.



# File 'lib/vips/methods.rb', line 52

#boolean_const(boolean, c, opts = {}) ⇒ Vips::Image

Boolean operations against a constant.



# File 'lib/vips/methods.rb', line 133

#buildlut(opts = {}) ⇒ Vips::Image

Build a look-up table.



# File 'lib/vips/methods.rb', line 793

#byteswap(opts = {}) ⇒ Vips::Image

Byteswap an image.



# File 'lib/vips/methods.rb', line 537

#cache(opts = {}) ⇒ Vips::Image

Cache an image.

Options Hash (opts):

  • :max_tiles (Integer)

    Maximum number of tiles to cache

  • :tile_height (Integer)

    Tile height in pixels

  • :tile_width (Integer)

    Tile width in pixels



# File 'lib/vips/methods.rb', line 306

#cast(format, opts = {}) ⇒ Vips::Image

Cast an image.

Options Hash (opts):

  • :shift (Boolean)

    Shift integer values up and down



# File 'lib/vips/methods.rb', line 439

#ceilImage

Return the smallest integral value not less than the argument.



997
998
999
# File 'lib/vips/image.rb', line 997

def ceil
    round :ceil
end

#CMC2LCh(opts = {}) ⇒ Vips::Image

Transform lch to cmc.



# File 'lib/vips/methods.rb', line 1633

#codingSymbol

Get image coding.



651
652
653
# File 'lib/vips/image.rb', line 651

def coding
    get "coding"
end

#colourspace(space, opts = {}) ⇒ Vips::Image

Convert to a new colorspace.

Options Hash (opts):



# File 'lib/vips/methods.rb', line 1599

#compass(mask, opts = {}) ⇒ Vips::Image

Convolve with rotating mask.

Options Hash (opts):

  • :times (Integer)

    Rotate and convolve this many times

  • :angle (Vips::Angle45)

    Rotate mask by this much between convolutions

  • :combine (Vips::Combine)

    Combine convolution results like this

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



# File 'lib/vips/methods.rb', line 1875

#complex(cmplx, opts = {}) ⇒ Vips::Image

Perform a complex operation on an image.



# File 'lib/vips/methods.rb', line 147

#complex2(right, cmplx, opts = {}) ⇒ Vips::Image

Complex binary operations on two images.



# File 'lib/vips/methods.rb', line 66

#complexform(right, opts = {}) ⇒ Vips::Image

Form a complex image from two real images.



# File 'lib/vips/methods.rb', line 73

#complexget(get, opts = {}) ⇒ Vips::Image

Get a component from a complex image.



# File 'lib/vips/methods.rb', line 153

#composite(other, mode, opts = {}) ⇒ Image

Composite a set of images with a set of blend modes.



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/vips/image.rb', line 1059

def composite other, mode, opts = {}
    unless other.is_a? Array
        other = [other]
    end
    unless mode.is_a? Array
        mode = [mode]
    end

    mode = mode.map do |x|
        GObject::GValue.from_nick Vips::BLEND_MODE_TYPE, x
    end

    Vips::Image.composite([self] + other, mode, opts)
end

#composite2(overlay, mode, opts = {}) ⇒ Vips::Image

Blend a pair of images with a blend mode.

Options Hash (opts):

  • :compositing_space (Vips::Interpretation)

    Composite images in this colour space

  • :premultiplied (Boolean)

    Images have premultiplied alpha



# File 'lib/vips/methods.rb', line 553

#conjImage

Return the complex conjugate of an image.

The image can be complex, in which case the return image will also be complex, or must have an even number of bands, in which case pairs of bands are treated as (x, y) coordinates.



1166
1167
1168
# File 'lib/vips/image.rb', line 1166

def conj
    Image::run_cmplx(self) {|x| x.complex :conj}
end

#conv(mask, opts = {}) ⇒ Vips::Image

Convolution operation.

Options Hash (opts):

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



# File 'lib/vips/methods.rb', line 1846

#conva(mask, opts = {}) ⇒ Vips::Image

Approximate integer convolution.

Options Hash (opts):

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



# File 'lib/vips/methods.rb', line 1855

#convasep(mask, opts = {}) ⇒ Vips::Image

Approximate separable integer convolution.

Options Hash (opts):

  • :layers (Integer)

    Use this many layers in approximation



# File 'lib/vips/methods.rb', line 1896

#convf(mask, opts = {}) ⇒ Vips::Image

Float convolution operation.



# File 'lib/vips/methods.rb', line 1863

#convi(mask, opts = {}) ⇒ Vips::Image

Int convolution operation.



# File 'lib/vips/methods.rb', line 1869

#convsep(mask, opts = {}) ⇒ Vips::Image

Seperable convolution operation.

Options Hash (opts):

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



# File 'lib/vips/methods.rb', line 1887

#copy(opts = {}) ⇒ Vips::Image

Copy an image.

Options Hash (opts):

  • :width (Integer)

    Image width in pixels

  • :height (Integer)

    Image height in pixels

  • :bands (Integer)

    Number of bands in image

  • :format (Vips::BandFormat)

    Pixel format in image

  • :coding (Vips::Coding)

    Pixel coding

  • :interpretation (Vips::Interpretation)

    Pixel interpretation

  • :xres (Float)

    Horizontal resolution in pixels/mm

  • :yres (Float)

    Vertical resolution in pixels/mm

  • :xoffset (Integer)

    Horizontal offset of origin

  • :yoffset (Integer)

    Vertical offset of origin



# File 'lib/vips/methods.rb', line 265

#copy_memoryImage

Copy an image to a memory area.

This can be useful for reusing results, but can obviously use a lot of memory for large images. See #tilecache for a way of caching parts of an image.



745
746
747
748
# File 'lib/vips/image.rb', line 745

def copy_memory
    new_image = Vips::vips_image_copy_memory self
    Vips::Image.new new_image
end

#cosImage

Return the cosine of an image in degrees.



1188
1189
1190
# File 'lib/vips/image.rb', line 1188

def cos
    math :cos
end

#countlines(direction, opts = {}) ⇒ Float

Count lines in an image.



# File 'lib/vips/methods.rb', line 1977

#cross_phase(other) ⇒ Image

Calculate the cross phase of two images.



1174
1175
1176
# File 'lib/vips/image.rb', line 1174

def cross_phase other
    complex2 other, :cross_phase
end

#csvsave(filename, opts = {}) ⇒ nil

Save image to csv file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :separator (String)

    Separator characters

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1179

#dE00(right, opts = {}) ⇒ Vips::Image

Calculate de00.



# File 'lib/vips/methods.rb', line 1748

#dE76(right, opts = {}) ⇒ Vips::Image

Calculate de76.



# File 'lib/vips/methods.rb', line 1742

#dECMC(right, opts = {}) ⇒ Vips::Image

Calculate decmc.



# File 'lib/vips/methods.rb', line 1754

#deviate(opts = {}) ⇒ Float

Find image standard deviation.



# File 'lib/vips/methods.rb', line 186

#dilate(mask) ⇒ Image

Dilate with a structuring element.

The structuring element must be an array with 0 for black, 255 for white and 128 for don't care.



1282
1283
1284
# File 'lib/vips/image.rb', line 1282

def dilate mask
    morph mask, :dilate
end

#divide(right, opts = {}) ⇒ Vips::Image

Divide two images.



# File 'lib/vips/methods.rb', line 33

#draw_circle(ink, cx, cy, radius, opts = {}) ⇒ Vips::Image

Draw a circle on an image.

Options Hash (opts):

  • :fill (Boolean)

    Draw a solid object



# File 'lib/vips/methods.rb', line 2025

#draw_flood(ink, x, y, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Flood-fill an area.

Options Hash (opts):

  • :test (Vips::Image)

    Test pixels in this image

  • :equal (Boolean)

    DrawFlood while equal to edge

  • :left (Integer)

    Output Left edge of modified area

  • :top (Integer)

    Output top edge of modified area

  • :width (Integer)

    Output width of modified area

  • :height (Integer)

    Output height of modified area



# File 'lib/vips/methods.rb', line 2035

#draw_image(sub, x, y, opts = {}) ⇒ Vips::Image

Paint an image into another image.

Options Hash (opts):

  • :mode (Vips::CombineMode)

    Combining mode



# File 'lib/vips/methods.rb', line 2049

#draw_line(ink, x1, y1, x2, y2, opts = {}) ⇒ Vips::Image

Draw a line on an image.



# File 'lib/vips/methods.rb', line 2015

#draw_mask(ink, mask, x, y, opts = {}) ⇒ Vips::Image

Draw a mask on an image.



# File 'lib/vips/methods.rb', line 2006

#draw_point(ink, left, top, opts = {}) ⇒ Image

Draw a point on an image.

See #draw_rect.



755
756
757
# File 'lib/vips/image.rb', line 755

def draw_point ink, left, top, opts = {}
    draw_rect ink, left, top, 1, 1, opts
end

#draw_rect(ink, left, top, width, height, opts = {}) ⇒ Vips::Image

Paint a rectangle on an image.

Options Hash (opts):

  • :fill (Boolean)

    Draw a solid object



# File 'lib/vips/methods.rb', line 1995

#draw_smudge(left, top, width, height, opts = {}) ⇒ Vips::Image

Blur a rectangle on an image.



# File 'lib/vips/methods.rb', line 2058

#dzsave(filename, opts = {}) ⇒ nil

Save image to deepzoom file.

Options Hash (opts):

  • :basename (String)

    Base name to save to

  • :layout (Vips::ForeignDzLayout)

    Directory layout

  • :page_height (Integer)

    Set page height for multipage save

  • :suffix (String)

    Filename suffix for tiles

  • :overlap (Integer)

    Tile overlap in pixels

  • :tile_size (Integer)

    Tile size in pixels

  • :centre (Boolean)

    Center image in tile

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :angle (Vips::Angle)

    Rotate image during save

  • :container (Vips::ForeignDzContainer)

    Pyramid container type

  • :properties (Boolean)

    Write a properties file to the output directory

  • :compression (Integer)

    ZIP deflate compression level

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1261

#dzsave_buffer(opts = {}) ⇒ VipsBlob

Save image to dz buffer.

Options Hash (opts):

  • :basename (String)

    Base name to save to

  • :layout (Vips::ForeignDzLayout)

    Directory layout

  • :page_height (Integer)

    Set page height for multipage save

  • :suffix (String)

    Filename suffix for tiles

  • :overlap (Integer)

    Tile overlap in pixels

  • :tile_size (Integer)

    Tile size in pixels

  • :centre (Boolean)

    Center image in tile

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :angle (Vips::Angle)

    Rotate image during save

  • :container (Vips::ForeignDzContainer)

    Pyramid container type

  • :properties (Boolean)

    Write a properties file to the output directory

  • :compression (Integer)

    ZIP deflate compression level

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1281

#embed(x, y, width, height, opts = {}) ⇒ Vips::Image

Embed an image in a larger image.

Options Hash (opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels



# File 'lib/vips/methods.rb', line 314

#erode(mask) ⇒ Image

Erode with a structuring element.

The structuring element must be an array with 0 for black, 255 for white and 128 for don't care.



1270
1271
1272
# File 'lib/vips/image.rb', line 1270

def erode mask
    morph mask, :erode
end

#expImage

Return e ** pixel.



1237
1238
1239
# File 'lib/vips/image.rb', line 1237

def exp
    math :exp
end

#exp10Image

Return 10 ** pixel.



1244
1245
1246
# File 'lib/vips/image.rb', line 1244

def exp10
    math :exp10
end

#extract_area(left, top, width, height, opts = {}) ⇒ Vips::Image

Extract an area from an image.



# File 'lib/vips/methods.rb', line 375

#extract_band(band, opts = {}) ⇒ Vips::Image

Extract band from an image.

Options Hash (opts):

  • :n (Integer)

    Number of bands to extract



# File 'lib/vips/methods.rb', line 401

#falsecolour(opts = {}) ⇒ Vips::Image

False-color an image.



# File 'lib/vips/methods.rb', line 542

#fastcor(ref, opts = {}) ⇒ Vips::Image

Fast correlation.



# File 'lib/vips/methods.rb', line 1903

#filenameString

Get image filename, if any.



658
659
660
# File 'lib/vips/image.rb', line 658

def filename
    get "filename"
end

#fill_nearest(opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Fill image zeros with nearest non-zero pixel.

Options Hash (opts):

  • :distance (Vips::Image)

    Output Distance to nearest non-zero pixel



# File 'lib/vips/methods.rb', line 1989

#find_trim(opts = {}) ⇒ Array<] Left edge of image, ...

Search an image for non-edge areas.

Options Hash (opts):

  • :threshold (Float)

    Object threshold

  • :background (Array<Double>)

    Color for background pixels



# File 'lib/vips/methods.rb', line 258

#fitssave(filename, opts = {}) ⇒ nil

Save image to fits file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1453

#flatten(opts = {}) ⇒ Vips::Image

Flatten alpha out of an image.

Options Hash (opts):

  • :background (Array<Double>)

    Background value

  • :max_alpha (Float)

    Maximum value of alpha channel



# File 'lib/vips/methods.rb', line 482

#flip(direction, opts = {}) ⇒ Vips::Image

Flip an image.



# File 'lib/vips/methods.rb', line 335

#fliphorImage

Flip horizontally.



1251
1252
1253
# File 'lib/vips/image.rb', line 1251

def fliphor
    flip :horizontal
end

#flipverImage

Flip vertically.



1258
1259
1260
# File 'lib/vips/image.rb', line 1258

def flipver
    flip :vertical
end

#float2rad(opts = {}) ⇒ Vips::Image

Transform float rgb to radiance coding.



# File 'lib/vips/methods.rb', line 1693

#floorImage

Return the largest integral value not greater than the argument.



990
991
992
# File 'lib/vips/image.rb', line 990

def floor
    round :floor
end

#formatSymbol

Get image format.



637
638
639
# File 'lib/vips/image.rb', line 637

def format
    get "format"
end

#freqmult(mask, opts = {}) ⇒ Vips::Image

Frequency-domain filtering.



# File 'lib/vips/methods.rb', line 1945

#fwfft(opts = {}) ⇒ Vips::Image

Forward fft.



# File 'lib/vips/methods.rb', line 1934

#gamma(opts = {}) ⇒ Vips::Image

Gamma an image.

Options Hash (opts):

  • :exponent (Float)

    Gamma factor



# File 'lib/vips/methods.rb', line 547

#gaussblur(sigma, opts = {}) ⇒ Vips::Image

Gaussian blur.

Options Hash (opts):

  • :min_ampl (Float)

    Minimum amplitude of Gaussian

  • :precision (Vips::Precision)

    Convolve with this precision



# File 'lib/vips/methods.rb', line 1926

#get(name) ⇒ Object

Get a metadata item from an image. Ruby types are constructed automatically from the GValue, if possible.

For example, you can read the ICC profile from an image like this:

profile = image.get "icc-profile-data"

and profile will be an array containing the profile.

Raises:



518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/vips/image.rb', line 518

def get name
    # with old libvips, we must fetch properties (as opposed to
    # metadata) via VipsObject
    unless Vips::at_least_libvips?(8, 5)
        return super if parent_get_typeof(name) != 0
    end

    gvalue = GObject::GValue.alloc
    result = Vips::vips_image_get self, name, gvalue
    raise Vips::Error if result != 0 

    return gvalue.get
end

#get_fields[String]

Get the names of all fields on an image. Use this to loop over all image metadata.



536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/vips/image.rb', line 536

def get_fields
    # vips_image_get_fields() was added in libvips 8.5
    return [] unless Vips.respond_to? :vips_image_get_fields

    array = Vips::vips_image_get_fields self

    names = []
    p = array
    until ((q = p.read_pointer).null?)
        names << q.read_string
        GLib::g_free q
        p += FFI::Type::POINTER.size
    end
    GLib::g_free array

    return names
end

#get_typeof(name) ⇒ Integer

Fetch a GType from an image. GType will be 0 for no such field.

See Also:



494
495
496
497
498
499
500
501
502
503
# File 'lib/vips/image.rb', line 494

def get_typeof name
    # on libvips before 8.5, property types must be searched first,
    # since vips_image_get_typeof returned built-in enums as int
    unless Vips::at_least_libvips?(8, 5)
        gtype = parent_get_typeof name
        return gtype if gtype != 0
    end

    Vips::vips_image_get_typeof self, name
end

#get_value(name) ⇒ Object

compatibility: old name for get



604
605
606
# File 'lib/vips/image.rb', line 604

def get_value name
    get name
end

#getpoint(x, y, opts = {}) ⇒ Array<Double>

Read a point from an image.



1101
1102
1103
1104
1105
1106
1107
1108
# File 'lib/vips/image.rb', line 1101

def getpoint x, y
    # vips has an operation that does this, but we can't call it via
    # gobject-introspection 3.1 since it's missing array double
    # get
    #
    # remove this def when gobject-introspection updates
    crop(x, y, 1, 1).bandsplit.map(&:avg)
end

#globalbalance(opts = {}) ⇒ Vips::Image

Global balance an image mosaic.

Options Hash (opts):

  • :gamma (Float)

    Image gamma

  • :int_output (Boolean)

    Integer output



# File 'lib/vips/methods.rb', line 2137

#gravity(direction, width, height, opts = {}) ⇒ Vips::Image

Place an image within a larger image with a certain gravity.

Options Hash (opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels



# File 'lib/vips/methods.rb', line 325

#grid(tile_height, across, down, opts = {}) ⇒ Vips::Image

Grid an image.



# File 'lib/vips/methods.rb', line 501

#has_alpha?Boolean

Detect if image has an alpha channel



719
720
721
# File 'lib/vips/image.rb', line 719

def has_alpha?
    return Vips::vips_image_hasalpha(self) != 0
end

#heightInteger

Get image height, in pixels.



623
624
625
# File 'lib/vips/image.rb', line 623

def height
    get "height"
end

#hist_cum(opts = {}) ⇒ Vips::Image

Form cumulative histogram.



# File 'lib/vips/methods.rb', line 1801

#hist_entropy(opts = {}) ⇒ Float

Estimate image entropy.



# File 'lib/vips/methods.rb', line 1841

#hist_equal(opts = {}) ⇒ Vips::Image

Histogram equalisation.

Options Hash (opts):

  • :band (Integer)

    Equalise with this band



# File 'lib/vips/methods.rb', line 1817

#hist_find(opts = {}) ⇒ Vips::Image

Find image histogram.

Options Hash (opts):

  • :band (Integer)

    Find histogram of band



# File 'lib/vips/methods.rb', line 196

#hist_find_indexed(index, opts = {}) ⇒ Vips::Image

Find indexed image histogram.

Options Hash (opts):

  • :combine (Vips::Combine)

    Combine bins like this



# File 'lib/vips/methods.rb', line 208

#hist_find_ndim(opts = {}) ⇒ Vips::Image

Find n-dimensional image histogram.

Options Hash (opts):

  • :bins (Integer)

    Number of bins in each dimension



# File 'lib/vips/methods.rb', line 202

#hist_ismonotonic(opts = {}) ⇒ Boolean

Test for monotonicity.



# File 'lib/vips/methods.rb', line 1836

#hist_local(width, height, opts = {}) ⇒ Vips::Image

Local histogram equalisation.

Options Hash (opts):

  • :max_slope (Integer)

    Maximum slope (CLAHE)



# File 'lib/vips/methods.rb', line 1828

#hist_match(ref, opts = {}) ⇒ Vips::Image

Match two histograms.



# File 'lib/vips/methods.rb', line 1806

#hist_norm(opts = {}) ⇒ Vips::Image

Normalise histogram.



# File 'lib/vips/methods.rb', line 1812

#hist_plot(opts = {}) ⇒ Vips::Image

Plot histogram.



# File 'lib/vips/methods.rb', line 1823

#hough_circle(opts = {}) ⇒ Vips::Image

Find hough circle transform.

Options Hash (opts):

  • :scale (Integer)

    Scale down dimensions by this factor

  • :min_radius (Integer)

    Smallest radius to search for

  • :max_radius (Integer)

    Largest radius to search for



# File 'lib/vips/methods.rb', line 222

#hough_line(opts = {}) ⇒ Vips::Image

Find hough line transform.

Options Hash (opts):

  • :width (Integer)

    horizontal size of parameter space

  • :height (Integer)

    Vertical size of parameter space



# File 'lib/vips/methods.rb', line 215

#HSV2sRGB(opts = {}) ⇒ Vips::Image

Transform hsv to srgb.



# File 'lib/vips/methods.rb', line 1708

#icc_export(opts = {}) ⇒ Vips::Image

Output to device with icc profile.

Options Hash (opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :output_profile (String)

    Filename to load output profile from

  • :depth (Integer)

    Output device space depth in bits



# File 'lib/vips/methods.rb', line 1722

#icc_import(opts = {}) ⇒ Vips::Image

Import from device with icc profile.

Options Hash (opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :embedded (Boolean)

    Use embedded input profile, if available

  • :input_profile (String)

    Filename to load input profile from



# File 'lib/vips/methods.rb', line 1713

#icc_transform(output_profile, opts = {}) ⇒ Vips::Image

Transform between devices with icc profiles.

Options Hash (opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :embedded (Boolean)

    Use embedded input profile, if available

  • :input_profile (String)

    Filename to load input profile from

  • :depth (Integer)

    Output device space depth in bits



# File 'lib/vips/methods.rb', line 1731

#ifthenelse(th, el, opts = {}) ⇒ Image

Select pixels from th if self is non-zero and from el if self is zero. Use the :blend option to fade smoothly between th and el.

Options Hash (opts):

  • :blend (Boolean) — default: false

    Blend smoothly between th and el



1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/vips/image.rb', line 1316

def ifthenelse(th, el, opts = {}) 
    match_image = [th, el, self].find {|x| x.is_a? Vips::Image}

    unless th.is_a? Vips::Image
        th = Operation.imageize match_image, th
    end
    unless el.is_a? Vips::Image
        el = Operation.imageize match_image, el
    end

    Vips::Operation.call "ifthenelse", [self, th, el], opts
end

#imagImage

Return the imaginary part of a complex image.



1128
1129
1130
# File 'lib/vips/image.rb', line 1128

def imag
    complexget :imag
end

#insert(sub, x, y, opts = {}) ⇒ Vips::Image

Insert image @sub into @main at @x, @y.

Options Hash (opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :background (Array<Double>)

    Color for new pixels



# File 'lib/vips/methods.rb', line 341

#inspectObject



179
180
181
182
# File 'lib/vips/image.rb', line 179

def inspect
    "#<Image #{width}x#{height} #{format}, #{bands} bands, " +
        "#{interpretation}>"
end

#interpretationSymbol

Get image interpretation.



644
645
646
# File 'lib/vips/image.rb', line 644

def interpretation
    get "interpretation"
end

#invert(opts = {}) ⇒ Vips::Image

Invert an image.



# File 'lib/vips/methods.rb', line 85

#invertlut(opts = {}) ⇒ Vips::Image

Build an inverted look-up table.

Options Hash (opts):

  • :size (Integer)

    LUT size to generate



# File 'lib/vips/methods.rb', line 798

#invfft(opts = {}) ⇒ Vips::Image

Inverse fft.

Options Hash (opts):

  • :real (Boolean)

    Output only the real part of the transform



# File 'lib/vips/methods.rb', line 1939

#join(in2, direction, opts = {}) ⇒ Vips::Image

Join a pair of images.

Options Hash (opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :align (Vips::Align)

    Align on the low, centre or high coordinate edge



# File 'lib/vips/methods.rb', line 351

#jpegsave(filename, opts = {}) ⇒ nil

Save image to jpeg file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :Q (Integer)

    Q factor

  • :profile (String)

    ICC profile to embed

  • :optimize_coding (Boolean)

    Compute optimal Huffman coding tables

  • :interlace (Boolean)

    Generate an interlaced (progressive) jpeg

  • :no_subsample (Boolean)

    Disable chroma subsample

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split the spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1325

#jpegsave_buffer(opts = {}) ⇒ VipsBlob

Save image to jpeg buffer.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :Q (Integer)

    Q factor

  • :profile (String)

    ICC profile to embed

  • :optimize_coding (Boolean)

    Compute optimal Huffman coding tables

  • :interlace (Boolean)

    Generate an interlaced (progressive) jpeg

  • :no_subsample (Boolean)

    Disable chroma subsample

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split the spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1343

#jpegsave_mime(opts = {}) ⇒ nil

Save image to jpeg mime.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :Q (Integer)

    Q factor

  • :profile (String)

    ICC profile to embed

  • :optimize_coding (Boolean)

    Compute optimal Huffman coding tables

  • :interlace (Boolean)

    Generate an interlaced (progressive) jpeg

  • :no_subsample (Boolean)

    Disable chroma subsample

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split the spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1360

#Lab2LabQ(opts = {}) ⇒ Vips::Image

Transform float lab to labq coding.



# File 'lib/vips/methods.rb', line 1663

#Lab2LabS(opts = {}) ⇒ Vips::Image

Transform float lab to signed short.



# File 'lib/vips/methods.rb', line 1683

#Lab2LCh(opts = {}) ⇒ Vips::Image

Transform lab to lch.



# File 'lib/vips/methods.rb', line 1618

#Lab2XYZ(opts = {}) ⇒ Vips::Image

Transform cielab to xyz.

Options Hash (opts):

  • :temp (Array<Double>)

    Color temperature



# File 'lib/vips/methods.rb', line 1606

#labelregions(opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Label regions in an image.

Options Hash (opts):

  • :segments (Integer)

    Output Number of discrete contigious regions



# File 'lib/vips/methods.rb', line 1983

#LabQ2Lab(opts = {}) ⇒ Vips::Image

Unpack a labq image to float lab.



# File 'lib/vips/methods.rb', line 1658

#LabQ2LabS(opts = {}) ⇒ Vips::Image

Unpack a labq image to short lab.



# File 'lib/vips/methods.rb', line 1668

#LabQ2sRGB(opts = {}) ⇒ Vips::Image

Convert a labq image to srgb.



# File 'lib/vips/methods.rb', line 1698

#LabS2Lab(opts = {}) ⇒ Vips::Image

Transform signed short lab to float.



# File 'lib/vips/methods.rb', line 1678

#LabS2LabQ(opts = {}) ⇒ Vips::Image

Transform short lab to labq coding.



# File 'lib/vips/methods.rb', line 1673

#LCh2CMC(opts = {}) ⇒ Vips::Image

Transform lch to cmc.



# File 'lib/vips/methods.rb', line 1628

#LCh2Lab(opts = {}) ⇒ Vips::Image

Transform lch to lab.



# File 'lib/vips/methods.rb', line 1623

#linear(a, b, opts = {}) ⇒ Vips::Image

Calculate (a * in + b).

Options Hash (opts):

  • :uchar (Boolean)

    Output should be uchar



# File 'lib/vips/methods.rb', line 90

#linecache(opts = {}) ⇒ Vips::Image

Cache an image as a set of lines.

Options Hash (opts):

  • :tile_height (Integer)

    Tile height in pixels

  • :access (Vips::Access)

    Expected access pattern

  • :threaded (Boolean)

    Allow threaded access

  • :persistent (Boolean)

    Keep cache between evaluations



# File 'lib/vips/methods.rb', line 291

#logImage

Return the natural log of an image.



1223
1224
1225
# File 'lib/vips/image.rb', line 1223

def log
    math :log
end

#log10Image

Return the log base 10 of an image.



1230
1231
1232
# File 'lib/vips/image.rb', line 1230

def log10
    math :log10
end

#mapim(index, opts = {}) ⇒ Vips::Image

Resample with an mapim image.

Options Hash (opts):



# File 'lib/vips/methods.rb', line 1506

#maplut(lut, opts = {}) ⇒ Vips::Image

Map an image though a lut.

Options Hash (opts):

  • :band (Integer)

    apply one-band lut to this band of in



# File 'lib/vips/methods.rb', line 1777

#match(sec, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, opts = {}) ⇒ Vips::Image

First-order match of two images.

Options Hash (opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :search (Boolean)

    Search to improve tie-points

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this



# File 'lib/vips/methods.rb', line 2119

#math(math, opts = {}) ⇒ Vips::Image

Apply a math operation to an image.



# File 'lib/vips/methods.rb', line 98

#math2(right, math2, opts = {}) ⇒ Vips::Image

Binary math operations.



# File 'lib/vips/methods.rb', line 59

#math2_const(math2, c, opts = {}) ⇒ Vips::Image

Binary math operations with a constant.



# File 'lib/vips/methods.rb', line 140

#matrixprint(opts = {}) ⇒ nil

Print matrix.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1198

#matrixsave(filename, opts = {}) ⇒ nil

Save image to matrix file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1189

#max(opts = {}) ⇒ Float, Hash<Symbol => Object>

Find image maximum.

Options Hash (opts):

  • :size (Integer)

    Number of maximum values to find

  • :x (Integer)

    Output Horizontal position of maximum

  • :y (Integer)

    Output Vertical position of maximum

  • :out_array (Array<Double>)

    Output Array of output values

  • :x_array (Array<Integer>)

    Output Array of horizontal positions

  • :y_array (Array<Integer>)

    Output Array of vertical positions



# File 'lib/vips/methods.rb', line 175

#maxposReal

Return the coordinates of the image maximum.



1078
1079
1080
1081
1082
1083
# File 'lib/vips/image.rb', line 1078

def maxpos
    v, opts = max x: true, y: true
    x = opts['x']
    y = opts['y']
    return v, x, y
end

#measure(h, v, opts = {}) ⇒ Vips::Image

Measure a set of patches on a color chart.

Options Hash (opts):

  • :left (Integer)

    Left edge of extract area

  • :top (Integer)

    Top edge of extract area

  • :width (Integer)

    Width of extract area

  • :height (Integer)

    Height of extract area



# File 'lib/vips/methods.rb', line 240

#median(size = 3) ⇒ Image

a median filter



1114
1115
1116
# File 'lib/vips/image.rb', line 1114

def median size = 3
    rank size, size, (size * size) / 2
end

#merge(sec, direction, dx, dy, opts = {}) ⇒ Vips::Image

Merge two images.

Options Hash (opts):

  • :mblend (Integer)

    Maximum blend size



# File 'lib/vips/methods.rb', line 2067

#min(opts = {}) ⇒ Float, Hash<Symbol => Object>

Find image minimum.

Options Hash (opts):

  • :size (Integer)

    Number of minimum values to find

  • :x (Integer)

    Output Horizontal position of minimum

  • :y (Integer)

    Output Vertical position of minimum

  • :out_array (Array<Double>)

    Output Array of output values

  • :x_array (Array<Integer>)

    Output Array of horizontal positions

  • :y_array (Array<Integer>)

    Output Array of vertical positions



# File 'lib/vips/methods.rb', line 164

#minposReal

Return the coordinates of the image minimum.



1089
1090
1091
1092
1093
1094
# File 'lib/vips/image.rb', line 1089

def minpos
    v, opts = min x: true, y: true
    x = opts['x']
    y = opts['y']
    return v, x, y
end

#morph(mask, morph, opts = {}) ⇒ Vips::Image

Morphology operation.



# File 'lib/vips/methods.rb', line 1962

#mosaic(sec, direction, xref, yref, xsec, ysec, opts = {}) ⇒ Vips::Image, Hash<Symbol => Object>

Mosaic two images.

Options Hash (opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :mblend (Integer)

    Maximum blend size

  • :bandno (Integer)

    Band to search for features on

  • :dx0 (Integer)

    Output Detected integer offset

  • :dy0 (Integer)

    Output Detected integer offset

  • :scale1 (Float)

    Output Detected scale

  • :angle1 (Float)

    Output Detected rotation

  • :dy1 (Float)

    Output Detected first-order displacement

  • :dx1 (Float)

    Output Detected first-order displacement



# File 'lib/vips/methods.rb', line 2077

#mosaic1(sec, direction, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, opts = {}) ⇒ Vips::Image

First-order mosaic of two images.

Options Hash (opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :search (Boolean)

    Search to improve tie-points

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :mblend (Integer)

    Maximum blend size

  • :bandno (Integer)

    Band to search for features on



# File 'lib/vips/methods.rb', line 2098

#msb(opts = {}) ⇒ Vips::Image

Pick most-significant byte from an image.

Options Hash (opts):

  • :band (Integer)

    Band to msb



# File 'lib/vips/methods.rb', line 531

#multiply(right, opts = {}) ⇒ Vips::Image

Multiply two images.



# File 'lib/vips/methods.rb', line 27

#new_from_image(value) ⇒ Image

A new image is created with the same width, height, format, interpretation, resolution and offset as self, but with every pixel set to the specified value.

You can pass an array to make a many-band image, or a single value to make a one-band image.



384
385
386
387
388
389
# File 'lib/vips/image.rb', line 384

def new_from_image value
    pixel = (Vips::Image.black(1, 1) + value).cast(format)
    image = pixel.embed 0, 0, width, height, extend: :copy
    image.copy interpretation: interpretation,
        xres: xres, yres: yres, xoffset: xoffset, yoffset: yoffset
end

#offsetFloat

Get offset metadata.



702
703
704
705
706
# File 'lib/vips/image.rb', line 702

def offset
    return 0 if get_typeof("offset") == 0

    get "offset"
end

#parent_get_typeofObject



67
# File 'lib/vips/image.rb', line 67

alias_method :parent_get_typeof, :get_typeof

#percent(percent, opts = {}) ⇒ Integer

Find threshold for percent of pixels.



# File 'lib/vips/methods.rb', line 1784

#phasecor(in2, opts = {}) ⇒ Vips::Image

Calculate phase correlation.



# File 'lib/vips/methods.rb', line 1956

#pngsave(filename, opts = {}) ⇒ nil

Save image to png file.

Options Hash (opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    ICC profile to embed

  • :filter (Vips::ForeignPngFilter)

    libpng row filter flag(s)

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1300

#pngsave_buffer(opts = {}) ⇒ VipsBlob

Save image to png buffer.

Options Hash (opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    ICC profile to embed

  • :filter (Vips::ForeignPngFilter)

    libpng row filter flag(s)

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1313

#polarImage

Return an image with rectangular pixels converted to polar.

The image can be complex, in which case the return image will also be complex, or must have an even number of bands, in which case pairs of bands are treated as (x, y) coordinates.

See Also:



1141
1142
1143
# File 'lib/vips/image.rb', line 1141

def polar
    Image::run_cmplx(self) {|x| x.complex :polar}
end

#ppmsave(filename, opts = {}) ⇒ nil

Save image to ppm file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :ascii (Boolean)

    save as ascii

  • :squash (Boolean)

    save as one bit

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1233

#premultiply(opts = {}) ⇒ Vips::Image

Premultiply image alpha.

Options Hash (opts):

  • :max_alpha (Float)

    Maximum value of alpha channel



# File 'lib/vips/methods.rb', line 489

#profile(opts = {}) ⇒ Array<] First non-zero pixel in column, First non-zero pixel in row

Find image profiles.



# File 'lib/vips/methods.rb', line 235

#project(opts = {}) ⇒ Array<] Sums of columns, Sums of rows

Find image projections.



# File 'lib/vips/methods.rb', line 230

#quadratic(coeff, opts = {}) ⇒ Vips::Image

Resample an image with a quadratic transform.

Options Hash (opts):



# File 'lib/vips/methods.rb', line 1557

#rad2float(opts = {}) ⇒ Vips::Image

Unpack radiance coding to float rgb.



# File 'lib/vips/methods.rb', line 1688

#radsave(filename, opts = {}) ⇒ nil

Save image to radiance file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1244

#radsave_buffer(opts = {}) ⇒ VipsBlob

Save image to radiance buffer.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1253

#rank(width, height, index, opts = {}) ⇒ Vips::Image

Rank filter.



# File 'lib/vips/methods.rb', line 1969

#rawsave(filename, opts = {}) ⇒ nil

Save image to raw file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1206

#rawsave_fd(fd, opts = {}) ⇒ nil

Write raw image to file descriptor.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1215

#realImage

Return the real part of a complex image.



1121
1122
1123
# File 'lib/vips/image.rb', line 1121

def real
    complexget :real
end

#recomb(m, opts = {}) ⇒ Vips::Image

Linear recombination with matrix.



# File 'lib/vips/methods.rb', line 464

#rectImage

Return an image with polar pixels converted to rectangular.

The image can be complex, in which case the return image will also be complex, or must have an even number of bands, in which case pairs of bands are treated as (x, y) coordinates.

See Also:



1154
1155
1156
# File 'lib/vips/image.rb', line 1154

def rect
    Image::run_cmplx(self) {|x| x.complex :rect}
end

#reduce(hshrink, vshrink, opts = {}) ⇒ Vips::Image

Reduce an image.

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention



# File 'lib/vips/methods.rb', line 1548

#reduceh(hshrink, opts = {}) ⇒ Vips::Image

Shrink an image horizontally.

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention



# File 'lib/vips/methods.rb', line 1532

#reducev(vshrink, opts = {}) ⇒ Vips::Image

Shrink an image vertically.

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention



# File 'lib/vips/methods.rb', line 1540

#relational(right, relational, opts = {}) ⇒ Vips::Image

Relational operation on two images.



# File 'lib/vips/methods.rb', line 39

#relational_const(relational, c, opts = {}) ⇒ Vips::Image

Relational operations against a constant.



# File 'lib/vips/methods.rb', line 120

#remainder(right, opts = {}) ⇒ Vips::Image

Remainder after integer division of two images.



# File 'lib/vips/methods.rb', line 46

#remainder_const(c, opts = {}) ⇒ Vips::Image

Remainder after integer division of an image and a constant.



# File 'lib/vips/methods.rb', line 127

#remove(name) ⇒ Object

Remove a metadata item from an image.



599
600
601
# File 'lib/vips/image.rb', line 599

def remove name
    Vips::vips_image_remove self, name
end

#replicate(across, down, opts = {}) ⇒ Vips::Image

Replicate an image.



# File 'lib/vips/methods.rb', line 432

#resize(scale, opts = {}) ⇒ Vips::Image

Resize an image.

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :vscale (Float)

    Vertical scale image by this factor



# File 'lib/vips/methods.rb', line 1591

#respond_to?(name, include_all = false) ⇒ Boolean



184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/vips/image.rb', line 184

def respond_to? name, include_all = false
    # To support keyword args, we need to tell Ruby that final image
    # arguments cannot be hashes of keywords. 
    #
    # https://makandracards.com/makandra/36013-heads-up-ruby-implicitly-converts-a-hash-to-keyword-arguments
    return false if name == :to_hash

    # respond to all vips operations by nickname
    return true if Vips::type_find("VipsOperation", name.to_s) != 0

    super
end

#rintImage

Return the nearest integral value.



1004
1005
1006
# File 'lib/vips/image.rb', line 1004

def rint
    round :rint
end

#rot(angle, opts = {}) ⇒ Vips::Image

Rotate an image.



# File 'lib/vips/methods.rb', line 446

#rot180Image

Rotate by 180 degrees clockwise.



1296
1297
1298
# File 'lib/vips/image.rb', line 1296

def rot180
    rot :d180
end

#rot270Image

Rotate by 270 degrees clockwise.



1303
1304
1305
# File 'lib/vips/image.rb', line 1303

def rot270
    rot :d270
end

#rot45(opts = {}) ⇒ Vips::Image

Rotate an image.

Options Hash (opts):



# File 'lib/vips/methods.rb', line 452

#rot90Image

Rotate by 90 degrees clockwise.



1289
1290
1291
# File 'lib/vips/image.rb', line 1289

def rot90
    rot :d90
end

#round(round, opts = {}) ⇒ Vips::Image

Perform a round function on an image.



# File 'lib/vips/methods.rb', line 114

#scaleFloat

Get scale metadata.



693
694
695
696
697
# File 'lib/vips/image.rb', line 693

def scale
    return 1 if get_typeof("scale") == 0

    get "scale"
end

#scaleimage(opts = {}) ⇒ Vips::Image

Scale an image to uchar. This is the vips scale operation, but renamed to avoid a clash with the .scale property.



1334
1335
1336
# File 'lib/vips/image.rb', line 1334

def scaleimage opts = {}
    Vips::Image.scale self, opts
end

#scRGB2BW(opts = {}) ⇒ Vips::Image

Convert scrgb to bw.

Options Hash (opts):

  • :depth (Integer)

    Output device space depth in bits



# File 'lib/vips/methods.rb', line 1765

#scRGB2sRGB(opts = {}) ⇒ Vips::Image

Convert an scrgb image to srgb.

Options Hash (opts):

  • :depth (Integer)

    Output device space depth in bits



# File 'lib/vips/methods.rb', line 1771

#scRGB2XYZ(opts = {}) ⇒ Vips::Image

Transform scrgb to xyz.



# File 'lib/vips/methods.rb', line 1648

#sequential(opts = {}) ⇒ Vips::Image

Check sequential access.

Options Hash (opts):

  • :tile_height (Integer)

    Tile height in pixels



# File 'lib/vips/methods.rb', line 300

#set(name, value) ⇒ Object

Set the value of a metadata item on an image. The metadata item must already exist. Ruby types are automatically transformed into the matching GValue, if possible.

For example, you can use this to set an image's ICC profile:

x = y.set "icc-profile-data", profile

where profile is an ICC profile held as a binary string object.

See Also:



592
593
594
# File 'lib/vips/image.rb', line 592

def set name, value
    set_type get_typeof(name), name, value
end

#set_type(gtype, name, value) ⇒ Object

Create a metadata item on an image, of the specifed type. Ruby types are automatically transformed into the matching GType, if possible.

For example, you can use this to set an image's ICC profile:

x = y.set_type Vips::BLOB_TYPE, "icc-profile-data", profile

where profile is an ICC profile held as a binary string object.

See Also:



570
571
572
573
574
575
# File 'lib/vips/image.rb', line 570

def set_type gtype, name, value
    gvalue = GObject::GValue.alloc
    gvalue.init gtype
    gvalue.set value
    Vips::vips_image_set self, name, gvalue
end

#set_value(name, value) ⇒ Object

compatibility: old name for set



609
610
611
# File 'lib/vips/image.rb', line 609

def set_value name, value
    set name, value
end

#sharpen(opts = {}) ⇒ Vips::Image

Unsharp masking for print.

Options Hash (opts):

  • :sigma (Float)

    Sigma of Gaussian

  • :x1 (Float)

    Flat/jaggy threshold

  • :y2 (Float)

    Maximum brightening

  • :y3 (Float)

    Maximum darkening

  • :m1 (Float)

    Slope for flat areas

  • :m2 (Float)

    Slope for jaggy areas



# File 'lib/vips/methods.rb', line 1915

#shrink(hshrink, vshrink, opts = {}) ⇒ Vips::Image

Shrink an image.



# File 'lib/vips/methods.rb', line 1513

#shrinkh(hshrink, opts = {}) ⇒ Vips::Image

Shrink an image horizontally.



# File 'lib/vips/methods.rb', line 1520

#shrinkv(vshrink, opts = {}) ⇒ Vips::Image

Shrink an image vertically.



# File 'lib/vips/methods.rb', line 1526

#sign(opts = {}) ⇒ Vips::Image

Unit vector of pixel.



# File 'lib/vips/methods.rb', line 109

#similarity(opts = {}) ⇒ Vips::Image

Similarity transform of an image.

Options Hash (opts):

  • :background (Array<Double>)

    Background value

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :scale (Float)

    Scale by this factor

  • :angle (Float)

    Rotate anticlockwise by this many degrees

  • :odx (Float)

    Horizontal output displacement

  • :ody (Float)

    Vertical output displacement

  • :idx (Float)

    Horizontal input displacement

  • :idy (Float)

    Vertical input displacement



# File 'lib/vips/methods.rb', line 1578

#sinImage

Return the sine of an image in degrees.



1181
1182
1183
# File 'lib/vips/image.rb', line 1181

def sin
    math :sin 
end

#sizeInteger

Get the image size.



711
712
713
# File 'lib/vips/image.rb', line 711

def size
    [width, height]
end

#smartcrop(width, height, opts = {}) ⇒ Vips::Image

Extract an area from an image.

Options Hash (opts):



# File 'lib/vips/methods.rb', line 393

#spcor(ref, opts = {}) ⇒ Vips::Image

Spatial correlation.



# File 'lib/vips/methods.rb', line 1909

#spectrum(opts = {}) ⇒ Vips::Image

Make displayable power spectrum.



# File 'lib/vips/methods.rb', line 1951

#sRGB2HSV(opts = {}) ⇒ Vips::Image

Transform srgb to hsv.



# File 'lib/vips/methods.rb', line 1703

#sRGB2scRGB(opts = {}) ⇒ Vips::Image

Convert an srgb image to scrgb.



# File 'lib/vips/methods.rb', line 1760

#stats(opts = {}) ⇒ Vips::Image

Find image average.



# File 'lib/vips/methods.rb', line 191

#stdif(width, height, opts = {}) ⇒ Vips::Image

Statistical difference.

Options Hash (opts):

  • :s0 (Float)

    New deviation

  • :b (Float)

    Weight of new deviation

  • :m0 (Float)

    New mean

  • :a (Float)

    Weight of new mean



# File 'lib/vips/methods.rb', line 1790

#subsample(xfac, yfac, opts = {}) ⇒ Vips::Image

Subsample an image.

Options Hash (opts):

  • :point (Boolean)

    Point sample



# File 'lib/vips/methods.rb', line 523

#subtract(right, opts = {}) ⇒ Vips::Image

Subtract two images.



# File 'lib/vips/methods.rb', line 21

#tanImage

Return the tangent of an image in degrees.



1195
1196
1197
# File 'lib/vips/image.rb', line 1195

def tan
    math :tan
end

#thumbnail_image(width, opts = {}) ⇒ Vips::Image

Generate thumbnail from image.

Options Hash (opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :auto_rotate (Boolean)

    Use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent



# File 'lib/vips/methods.rb', line 1492

#tiffsave(filename, opts = {}) ⇒ nil

Save image to tiff file.

Options Hash (opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    ICC profile to embed

  • :tile (Boolean)

    Write a tiled tiff

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :pyramid (Boolean)

    Write a pyramidal tiff

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :squash (Boolean)

    Squash images down to 1 bit

  • :resunit (Vips::ForeignTiffResunit)

    Resolution unit

  • :xres (Float)

    Horizontal resolution in pixels/mm

  • :yres (Float)

    Vertical resolution in pixels/mm

  • :bigtiff (Boolean)

    Write a bigtiff image

  • :properties (Boolean)

    Write a properties document to IMAGEDESCRIPTION

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1406

#tiffsave_buffer(opts = {}) ⇒ VipsBlob

Save image to tiff buffer.

Options Hash (opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    ICC profile to embed

  • :tile (Boolean)

    Write a tiled tiff

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :pyramid (Boolean)

    Write a pyramidal tiff

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :squash (Boolean)

    Squash images down to 1 bit

  • :resunit (Vips::ForeignTiffResunit)

    Resolution unit

  • :xres (Float)

    Horizontal resolution in pixels/mm

  • :yres (Float)

    Vertical resolution in pixels/mm

  • :bigtiff (Boolean)

    Write a bigtiff image

  • :properties (Boolean)

    Write a properties document to IMAGEDESCRIPTION

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1430

#tilecache(opts = {}) ⇒ Vips::Image

Cache an image as a set of tiles.

Options Hash (opts):

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :max_tiles (Integer)

    Maximum number of tiles to cache

  • :access (Vips::Access)

    Expected access pattern

  • :threaded (Boolean)

    Allow threaded access

  • :persistent (Boolean)

    Keep cache between evaluations



# File 'lib/vips/methods.rb', line 280

#to_aArray

Convert to an Array. This will be slow for large images.



956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
# File 'lib/vips/image.rb', line 956

def to_a
    # we render the image to a big string, then unpack 
    # as a Ruby array of the correct type
    memory = write_to_memory

    # make the template for unpack
    template = {
        :char => 'c',
        :uchar => 'C',
        :short => 's_',
        :ushort => 'S_',
        :int => 'i_',
        :uint => 'I_',
        :float => 'f',
        :double => 'd',
        :complex => 'f',
        :dpcomplex => 'd'
    }[format] + '*'

    # and unpack into something like [1, 2, 3, 4 ..]
    array = memory.unpack(template)

    # gather band elements together
    pixel_array = array.each_slice(bands).to_a

    # build rows 
    row_array = pixel_array.each_slice(width).to_a

    return row_array
end

#unpremultiply(opts = {}) ⇒ Vips::Image

Unpremultiply image alpha.

Options Hash (opts):

  • :max_alpha (Float)

    Maximum value of alpha channel



# File 'lib/vips/methods.rb', line 495

#vipssave(filename, opts = {}) ⇒ nil

Save image to vips file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1224

#webpsave(filename, opts = {}) ⇒ nil

Save image to webp file.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    enable lossless compression

  • :preset (Vips::ForeignWebpPreset)

    Preset for lossy compression

  • :smart_subsample (Boolean)

    Enable high quality chroma subsampling

  • :near_lossless (Boolean)

    Enable preprocessing in lossless mode (uses Q)

  • :alpha_q (Integer)

    Change alpha plane fidelity for lossy compression

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1377

#webpsave_buffer(opts = {}) ⇒ VipsBlob

Save image to webp buffer.

Options Hash (opts):

  • :page_height (Integer)

    Set page height for multipage save

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    enable lossless compression

  • :preset (Vips::ForeignWebpPreset)

    Preset for lossy compression

  • :smart_subsample (Boolean)

    Enable high quality chroma subsampling

  • :near_lossless (Boolean)

    Enable preprocessing in lossless mode (uses Q)

  • :alpha_q (Integer)

    Change alpha plane fidelity for lossy compression

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value



# File 'lib/vips/methods.rb', line 1392

#widthInteger

Get image width, in pixels.



616
617
618
# File 'lib/vips/image.rb', line 616

def width
    get "width"
end

#wrap(opts = {}) ⇒ Vips::Image

Wrap image origin.

Options Hash (opts):

  • :x (Integer)

    Left edge of input in output

  • :y (Integer)

    Top edge of input in output



# File 'lib/vips/methods.rb', line 509

#write_to_buffer(format_string, opts = {}) ⇒ String

Write this image to a memory buffer. Save options may be encoded in the format_string or given as a hash. For example:

buffer = image.write_to_buffer ".jpg[Q=90]"

or equivalently:

image.write_to_buffer ".jpg", Q: 90

The full set of save options depend on the selected saver. Try something like:

$ vips jpegsave

to see all the available options for JPEG save.

Options Hash (opts):

  • :strip (Boolean) — default: false

    Strip all metadata from image

  • :background (Array<Float>) — default: 0

    Background colour to flatten alpha against, if necessary

Raises:



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/vips/image.rb', line 458

def write_to_buffer format_string, opts = {}
    filename = 
        Vips::p2str(Vips::vips_filename_get_filename format_string)
    option_string = 
        Vips::p2str(Vips::vips_filename_get_options format_string)
    saver = Vips::vips_foreign_find_save_buffer filename
    if saver == nil
        raise Vips::Error, "No known saver for '#{filename}'."
    end

    buffer = Vips::Operation.call saver, [self], opts, option_string
    raise Vips::Error if buffer == nil

    write_gc

    return buffer
end

#write_to_file(name, opts = {}) ⇒ Object

Write this image to a file. Save options may be encoded in the filename or given as a hash. For example:

image.write_to_file "fred.jpg[Q=90]"

or equivalently:

image.write_to_file "fred.jpg", Q: 90

The full set of save options depend on the selected saver. Try something like:

$ vips jpegsave

to see all the available options for JPEG save.

Options Hash (opts):

  • :strip (Boolean) — default: false

    Strip all metadata from image

  • :background (Array<Float>) — default: 0

    Background colour to flatten alpha against, if necessary



420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/vips/image.rb', line 420

def write_to_file name, opts = {}
    filename = Vips::p2str(Vips::vips_filename_get_filename name)
    option_string = Vips::p2str(Vips::vips_filename_get_options name)
    saver = Vips::vips_foreign_find_save filename
    if saver == nil
        raise Vips::Error, "No known saver for '#{filename}'."
    end

    Vips::Operation.call saver, [self, filename], opts, option_string
 
    write_gc
end

#write_to_memoryString

Write this image to a large memory buffer.



479
480
481
482
483
484
485
486
487
# File 'lib/vips/image.rb', line 479

def write_to_memory
    len = Vips::SizeStruct.new
    ptr = Vips::vips_image_write_to_memory self, len

    # wrap up as an autopointer
    ptr = FFI::AutoPointer.new(ptr, GLib::G_FREE)

    ptr.get_bytes 0, len[:value]
end

#xoffsetInteger

Get image xoffset.



665
666
667
# File 'lib/vips/image.rb', line 665

def xoffset
    get "xoffset"
end

#xresFloat

Get image x resolution.



679
680
681
# File 'lib/vips/image.rb', line 679

def xres
    get "xres"
end

#XYZ2Lab(opts = {}) ⇒ Vips::Image

Transform xyz to lab.

Options Hash (opts):

  • :temp (Array<Double>)

    Colour temperature



# File 'lib/vips/methods.rb', line 1612

#XYZ2scRGB(opts = {}) ⇒ Vips::Image

Transform xyz to scrgb.



# File 'lib/vips/methods.rb', line 1653

#XYZ2Yxy(opts = {}) ⇒ Vips::Image

Transform xyz to yxy.



# File 'lib/vips/methods.rb', line 1638

#yoffsetInteger

Get image yoffset.



672
673
674
# File 'lib/vips/image.rb', line 672

def yoffset
    get "yoffset"
end

#yresFloat

Get image y resolution.



686
687
688
# File 'lib/vips/image.rb', line 686

def yres
    get "yres"
end

#Yxy2XYZ(opts = {}) ⇒ Vips::Image

Transform yxy to xyz.



# File 'lib/vips/methods.rb', line 1643

#zoom(xfac, yfac, opts = {}) ⇒ Vips::Image

Zoom an image.



# File 'lib/vips/methods.rb', line 516

#|(other) ⇒ Image

Integer bitwise OR with an image, constant or array.



832
833
834
# File 'lib/vips/image.rb', line 832

def | other
    call_enum "boolean", other, :or
end

#~Image

Equivalent to image ^ -1



862
863
864
# File 'lib/vips/image.rb', line 862

def ~
    self ^ -1
end