Class: Vips::Image

Inherits:
Object
  • 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 module.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

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

Parameters:

  • name (String)

    vips operation to call

Returns:

  • result of vips operation



394
395
396
# File 'lib/vips/image.rb', line 394

def method_missing(name, *args)
    Vips::call_base(name.to_s, self, "", args)
end

Instance Attribute Details

#bandsInteger (readonly)

Returns image bands.

Returns:

  • (Integer)

    image bands



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

#codingVips::Coding (readonly)

Returns image coding.

Returns:



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

#filenameString (readonly)

Returns image filename.

Returns:

  • (String)

    image filename



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

#formatVips::BandFormat (readonly)

Returns image format.

Returns:



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

#heightInteger (readonly)

Returns image height, in pixels.

Returns:

  • (Integer)

    image height, in pixels



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

#interpretationVips::Interpretation (readonly)

Returns image interpretation.

Returns:



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

#widthInteger (readonly)

Returns image width, in pixels.

Returns:

  • (Integer)

    image width, in pixels



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

#xresFloat (readonly)

Returns horizontal image resolution, in pixels per mm.

Returns:

  • (Float)

    horizontal image resolution, in pixels per mm



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

#yresFloat (readonly)

Returns vertical image resolution, in pixels per mm.

Returns:

  • (Float)

    vertical image resolution, in pixels per mm



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

Class Method Details

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

Load an analyze6 image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

.arrayjoinVips::Image

Join an array of images.

Parameters:

  • in (Array<Image>)

    Array of input images

  • opts (Hash)

    Set of options

Returns:



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

.bandrankVips::Image

Band-wise rank of a set of images.

Parameters:

  • in (Array<Image>)

    Array of input images

  • opts (Hash)

    Set of options

Returns:



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

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

Make a black image.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :bands (Integer)

    Number of bands in image

Returns:



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

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

Load csv from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :skip (Integer)

    Skip this many lines at the start of the file

  • :fail (Boolean)

    Fail on first warning

  • :lines (Integer)

    Read this many lines from the file

  • :whitespace (String)

    Set of whitespace characters

  • :separator (String)

    Set of separator characters

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make an image showing the eye's spatial response.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :factor (Float)

    Maximum spatial frequency

Returns:



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

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

Load a fits image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a fractal surface.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • fractal_dimension (Float)

    Fractal dimension

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Make a gaussian image.

Parameters:

  • sigma (Float)

    Sigma of Gaussian

  • min_ampl (Float)

    Minimum amplitude of Gaussian

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :separable (Boolean)

    Generate separable Gaussian

  • :precision (Vips::Precision)

    Generate with this precision

Returns:



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

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

Make a gaussnoise image.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :mean (Float)

    Mean of pixels in generated image

  • :sigma (Float)

    Standard deviation of pixels in generated image

Returns:



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

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

Load gif with giflib.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :n (Integer)

    Load this many pages

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load gif with giflib.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :n (Integer)

    Load this many pages

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a grey ramp image.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

Returns:



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

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

Make a 1d image where pixel values are indexes.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :bands (Integer)

    Number of bands in LUT

  • :ushort (Boolean)

    Create a 16-bit LUT

  • :size (Integer)

    Size of 16-bit LUT

Returns:



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

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

Load jpeg from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first warning

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load jpeg from buffer.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first warning

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a laplacian of gaussian image.

Parameters:

  • sigma (Float)

    Radius of Logmatian

  • min_ampl (Float)

    Minimum amplitude of Logmatian

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :separable (Boolean)

    Generate separable Logmatian

  • :precision (Vips::Precision)

    Generate with this precision

Returns:



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

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

Load file with imagemagick.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

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

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load buffer with imagemagick.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

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

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a butterworth filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • order (Float)

    Filter order

  • frequency_cutoff (Float)

    Frequency cutoff

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make a butterworth_band filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • order (Float)

    Filter order

  • frequency_cutoff_x (Float)

    Frequency cutoff x

  • frequency_cutoff_y (Float)

    Frequency cutoff y

  • radius (Float)

    radius of circle

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make a butterworth ring filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • order (Float)

    Filter order

  • frequency_cutoff (Float)

    Frequency cutoff

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • ringwidth (Float)

    Ringwidth

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make fractal filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • fractal_dimension (Float)

    Fractal dimension

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make a gaussian filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff (Float)

    Frequency cutoff

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make a gaussian filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff_x (Float)

    Frequency cutoff x

  • frequency_cutoff_y (Float)

    Frequency cutoff y

  • radius (Float)

    radius of circle

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make a gaussian ring filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff (Float)

    Frequency cutoff

  • amplitude_cutoff (Float)

    Amplitude cutoff

  • ringwidth (Float)

    Ringwidth

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make an ideal filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff (Float)

    Frequency cutoff

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make an ideal band filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff_x (Float)

    Frequency cutoff x

  • frequency_cutoff_y (Float)

    Frequency cutoff y

  • radius (Float)

    radius of circle

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Make an ideal ring filter.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • frequency_cutoff (Float)

    Frequency cutoff

  • ringwidth (Float)

    Ringwidth

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :optical (Boolean)

    Rotate quadrants to optical space

  • :reject (Boolean)

    Invert the sense of the filter

  • :nodc (Boolean)

    Remove DC component

Returns:



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

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

Load mat from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load matrix from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

.method_missing(name, *args) ⇒ Object

Invoke a vips operation with Vips.call.



399
400
401
# File 'lib/vips/image.rb', line 399

def self.method_missing(name, *args)
    Vips::call_base name.to_s, nil, "", args
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.

Parameters:

  • array (Array)

    the pixel data as an array of numbers

  • scale (Real) (defaults to: 1)

    the convolution scale

  • offset (Real) (defaults to: 0)

    the convolution offset

Returns:



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/vips/image.rb', line 521

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
    if not 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
        if not array.all? {|x| x.is_a? Array}
            raise Vips::Error, "Not a 2D array."
        end
        if not array.all? {|x| x.length == width}
            raise Vips::Error, "Array not rectangular."
        end
        array = array.flatten
    else
        height = 1
        width = array.length
    end

    if not 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
    if image == nil
        raise Vips::Error
    end

    # be careful to set them as double
    image.set_double 'scale', scale.to_f
    image.set_double '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::new_from_from_buffer memory_buffer, "shrink=2"

or alternatively:

image = Vips::new_from_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.

Parameters:

  • data (String)

    the data to load from

  • option_string (String)

    load options as a string

  • opts (Hash) (defaults to: {})

    set of options

Options Hash (opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

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

    Access mode for file

Returns:

  • (Image)

    the loaded image



486
487
488
489
490
491
492
493
# File 'lib/vips/image.rb', line 486

def self.new_from_buffer(data, option_string, opts = {})
    loader = Vips::Foreign.find_load_buffer data
    if loader == nil
        raise Vips::Error
    end

    Vips::call_base loader, nil, option_string, [data, opts]
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.

Parameters:

  • name (String)

    the filename to load from

  • opts (Hash) (defaults to: {})

    set of options

Options Hash (opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

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

    Access mode for file

Returns:

  • (Image)

    the loaded image



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/vips/image.rb', line 439

def self.new_from_file(name, opts = {})
    # very common, and Vips::filename_get_filename will segv if we pass
    # this
    if name == nil
        raise Error, "filename is nil"
    end
    filename = Vips::filename_get_filename name
    option_string = Vips::filename_get_options name
    loader = Vips::Foreign.find_load filename
    if loader == nil
        raise Vips::Error
    end

    Vips::call_base loader, nil, option_string, [filename, opts]
end

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

Load an openexr image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load file with openslide.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :level (Integer)

    Load this level from the file

  • :fail (Boolean)

    Fail on first warning

  • :autocrop (Boolean)

    Crop to image bounds

  • :associated (String)

    Load this associated image

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load pdf with libpoppler.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first warning

  • :n (Integer)

    Load this many pages

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load pdf with libpoppler.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the file

  • :fail (Boolean)

    Fail on first warning

  • :n (Integer)

    Load this many pages

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a perlin noise image.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :cell_size (Integer)

    Size of Perlin cells

  • :uchar (Boolean)

    Output an unsigned char image

Returns:



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

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

Load png from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load png from buffer.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load ppm from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load a radiance image from a file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load raw data from a file.

Parameters:

  • filename (String)

    Filename to load from

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • bands (Integer)

    Number of bands in image

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :offset (Integer)

    Offset in bytes from start of file

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a 2d sine wave.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :hfreq (Float)

    Horizontal spatial frequency

  • :vfreq (Float)

    Vertical spatial frequency

Returns:



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

.sumVips::Image

Sum an array of images.

Parameters:

  • in (Array<Image>)

    Array of input images

  • opts (Hash)

    Set of options

Returns:



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

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

Load svg with rsvg.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load svg with rsvg.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Run an external command.

Parameters:

  • cmd_format (String)

    Command to run

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :in (Array<Image>)

    Array of input images

  • :in_format (String)

    Format for input filename

  • :out_format (String)

    Format for output filename

  • :out (Vips::Image)

    Output Output image

  • :log (String)

    Output Command log

Returns:

  • (nil, Hash<Symbol => Object>)

    Hash of optional output items



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

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

Make a text image.

Parameters:

  • text (String)

    Text to render

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :font (String)

    Font to render with

  • :width (Integer)

    Maximum image width in pixels

  • :align (Vips::Align)

    Align on the low, centre or high edge

  • :dpi (Integer)

    DPI to render at

  • :spacing (Integer)

    Line spacing

Returns:



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

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

Generate thumbnail from file.

Parameters:

  • filename (String)

    Filename to read from

  • width (Integer)

    Size to this width

  • opts (Hash) (defaults to: {})

    Set of options

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 (Boolean)

    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

Returns:



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

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

Generate thumbnail from buffer.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • width (Integer)

    Size to this width

  • opts (Hash) (defaults to: {})

    Set of options

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 (Boolean)

    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

Returns:



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

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

Load tiff from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the image

  • :fail (Boolean)

    Fail on first warning

  • :n (Integer)

    Load this many pages

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load tiff from buffer.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :page (Integer)

    Load this page from the image

  • :fail (Boolean)

    Fail on first warning

  • :n (Integer)

    Load this many pages

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Build a look-up table.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Load vips from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load webp from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Load webp from buffer.

Parameters:

  • buffer (Vips::Blob)

    Buffer to load from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :disc (Boolean)

    Open to disc

  • :access (Vips::Access)

    Required access pattern for this file

  • :shrink (Integer)

    Shrink factor on load

  • :fail (Boolean)

    Fail on first warning

  • :flags (Vips::ForeignFlags)

    Output Flags for this file

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

Make a worley noise image.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :cell_size (Integer)

    Size of Worley cells

Returns:



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

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

Make an image where pixel values are coordinates.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :csize (Integer)

    Size of third dimension

  • :dsize (Integer)

    Size of fourth dimension

  • :esize (Integer)

    Size of fifth dimension

Returns:



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

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

Make a zone plate.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output an unsigned char image

Returns:



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

Instance Method Details

#!Image

Equivalent to image ^ -1

Returns:

  • (Image)

    image with bits flipped



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

def !
    self ^ -1
end

#!=(other) ⇒ Image

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

Parameters:

  • other (nil, Image, Real, Array<Real>)

    test inequality to this

Returns:

  • (Image)

    result of inequality



933
934
935
936
937
938
939
940
941
# File 'lib/vips/image.rb', line 933

def !=(other)
    if other == nil
        true
    elsif other.is_a?(Vips::Image) 
        relational(other, :noteq) 
    else
        relational_const(other, :noteq)
    end
end

#%(other) ⇒ Image

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

Parameters:

  • other (Image, Real, Array<Real>)

    self modulo this

Returns:

  • (Image)

    result of modulo



792
793
794
795
# File 'lib/vips/image.rb', line 792

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

#&(other) ⇒ Image

Integer bitwise AND with an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    bitwise AND with this

Returns:

  • (Image)

    result of bitwise AND



837
838
839
840
# File 'lib/vips/image.rb', line 837

def &(other)
    other.is_a?(Vips::Image) ? 
        boolean(other, :and) : boolean_const(other, :and)
end

#*(other) ⇒ Image

Multiply an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    Thing to multiply by self

Returns:

  • (Image)

    result of multiplication



775
776
777
# File 'lib/vips/image.rb', line 775

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

#**(other) ⇒ Image

Raise to power of an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    self to the power of this

Returns:

  • (Image)

    result of power



801
802
803
804
# File 'lib/vips/image.rb', line 801

def **(other)
    other.is_a?(Vips::Image) ? 
        math2(other, :pow) : math2_const(other, :pow)
end

#+(other) ⇒ Image

Add an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    Thing to add to self

Returns:

  • (Image)

    result of addition



758
759
760
# File 'lib/vips/image.rb', line 758

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

#+@Image

Returns image.

Returns:



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

def +@
    self
end

#-(other) ⇒ Image

Subtract an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    Thing to subtract from self

Returns:

  • (Image)

    result of subtraction



766
767
768
769
# File 'lib/vips/image.rb', line 766

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

#-@Image

Equivalent to image * -1

Returns:

  • (Image)

    negative of image



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

def -@
    self * -1
end

#/(other) ⇒ Image

Divide an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    Thing to divide self by

Returns:

  • (Image)

    result of division



783
784
785
786
# File 'lib/vips/image.rb', line 783

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.

Parameters:

  • other (Image, Real, Array<Real>)

    relational less than with this

Returns:

  • (Image)

    result of less than



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

def <(other)
    other.is_a?(Vips::Image) ? 
        relational(other, :less) : relational_const(other, :less)
end

#<<(other) ⇒ Image

Integer left shift with an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    shift left by this much

Returns:

  • (Image)

    result of left shift



810
811
812
813
# File 'lib/vips/image.rb', line 810

def <<(other)
    other.is_a?(Vips::Image) ? 
        boolean(other, :lshift) : boolean_const(other, :lshift)
end

#<=(other) ⇒ Image

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

Parameters:

  • other (Image, Real, Array<Real>)

    relational less than or equal to with this

Returns:

  • (Image)

    result of less than or equal to



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

def <=(other)
    other.is_a?(Vips::Image) ? 
        relational(other, :lesseq) : relational_const(other, :lesseq)
end

#==(other) ⇒ Image

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

Parameters:

  • other (nil, Image, Real, Array<Real>)

    test equality to this

Returns:

  • (Image)

    result of equality



919
920
921
922
923
924
925
926
927
# File 'lib/vips/image.rb', line 919

def ==(other)
    if other == nil
        false
    elsif other.is_a?(Vips::Image)  
        relational(other, :equal) 
    else
        relational_const(other, :equal)
    end
end

#>(other) ⇒ Image

Relational more than with an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    relational more than with this

Returns:

  • (Image)

    result of more than



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

def >(other)
    other.is_a?(Vips::Image) ? 
        relational(other, :more) : relational_const(other, :more)
end

#>=(other) ⇒ Image

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

Parameters:

  • other (Image, Real, Array<Real>)

    relational more than or equal to with this

Returns:

  • (Image)

    result of more than or equal to



910
911
912
913
# File 'lib/vips/image.rb', line 910

def >=(other)
    other.is_a?(Vips::Image) ? 
        relational(other, :moreeq) : relational_const(other, :moreeq)
end

#>>(other) ⇒ Image

Integer right shift with an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    shift right by this much

Returns:

  • (Image)

    result of right shift



819
820
821
822
# File 'lib/vips/image.rb', line 819

def >>(other)
    other.is_a?(Vips::Image) ? 
        boolean(other, :rshift) : boolean_const(other, :rshift)
end

#[](index) ⇒ Image

Fetch bands using a number or a range

Parameters:

  • index (Numeric, Range)

    extract these band(s)

Returns:

  • (Image)

    extracted band(s)



947
948
949
950
951
952
953
954
955
956
957
# File 'lib/vips/image.rb', line 947

def [](index)
    if index.is_a? Range
        n = index.end - index.begin
        n += 1 if not index.exclude_end?
        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.

Parameters:

  • other (Image, Real, Array<Real>)

    bitwise EOR with this

Returns:

  • (Image)

    result of bitwise EOR



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

def ^(other)
    other.is_a?(Vips::Image) ? 
        boolean(other, :eor) : boolean_const(other, :eor)
end

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

Absolute value of an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#acosImage

Return the inverse cosine of an image in degrees.

Returns:

  • (Image)

    inverse cosine of each pixel



1162
1163
1164
# File 'lib/vips/image.rb', line 1162

def acos
    math :acos
end

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

Add two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Affine transform of an image.

Parameters:

  • matrix (Array<Double>)

    Transformation matrix

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

#asinImage

Return the inverse sine of an image in degrees.

Returns:

  • (Image)

    inverse sine of each pixel



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

def asin
    math :asin
end

#atanImage

Return the inverse tangent of an image in degrees.

Returns:

  • (Image)

    inverse tangent of each pixel



1169
1170
1171
# File 'lib/vips/image.rb', line 1169

def atan
    math :atan
end

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

Autorotate image by exif tag.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :angle (Vips::Angle)

    Output Angle image was rotated by

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

#avg(opts = {}) ⇒ Float

Find image average.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Float)

    Output value



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

#bandandImage

AND the bands of an image together

Returns:

  • (Image)

    all bands ANDed together



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

def bandand
    bandbool :and
end

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

Boolean operation across image bands.

Parameters:

  • boolean (Vips::OperationBoolean)

    boolean to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#bandeorImage

EOR the bands of an image together

Returns:

  • (Image)

    all bands EORed together



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

def bandeor
    bandbool :eor
end

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

Fold up x axis into bands.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :factor (Integer)

    Fold by this factor

Returns:



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

#bandjoin(other) ⇒ Image

Join a set of images bandwise.

Parameters:

  • other (Image, Array<Image>, Real, Array<Real>)

    bands to append

Returns:

  • (Image)

    many band image



1027
1028
1029
1030
1031
1032
1033
# File 'lib/vips/image.rb', line 1027

def bandjoin(other)
    if not other.is_a? Array
        other = [other]
    end

    Vips::Image.bandjoin([self] + other)
end

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

Append a constant band to an image.

Parameters:

  • c (Array<Double>)

    Array of constants to add

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Band-wise average.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#bandorImage

OR the bands of an image together

Returns:

  • (Image)

    all bands ORed together



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

def bandor
    bandbool :or
end

#bandsplitArray<Image>

Split an n-band image into n separate images.

Returns:

  • (Array<Image>)

    Array of n one-band images



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

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

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

Unfold image bands into x axis.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :factor (Integer)

    Unfold by this factor

Returns:



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

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

Boolean operation on two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • boolean (Vips::OperationBoolean)

    boolean to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Boolean operations against a constant.

Parameters:

  • c (Array<Double>)

    Array of constants

  • boolean (Vips::OperationBoolean)

    boolean to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Build a look-up table.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Byteswap an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Cache an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Cast an image.

Parameters:

  • format (Vips::BandFormat)

    Format to cast to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :shift (Boolean)

    Shift integer values up and down

Returns:



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

#ceilImage

Return the smallest integral value not less than the argument.

Returns:

  • (Image)

    ceil of image



984
985
986
# File 'lib/vips/image.rb', line 984

def ceil
    round :ceil
end

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

Transform lch to cmc.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Convert to a new colourspace.

Parameters:

  • space (Vips::Interpretation)

    Destination colour space

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

Returns:



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

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

Convolve with rotating mask.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Perform a complex operation on an image.

Parameters:

  • cmplx (Vips::OperationComplex)

    complex to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Complex binary operations on two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • cmplx (Vips::OperationComplex2)

    binary complex operation to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Form a complex image from two real images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Get a component from a complex image.

Parameters:

  • get (Vips::OperationComplexget)

    complex to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#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.

Returns:

  • (Image)

    complex conjugate



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

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

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

Convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Approximate integer convolution.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation

Returns:



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

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

Approximate separable integer convolution.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :layers (Integer)

    Use this many layers in approximation

Returns:



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

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

Float convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Int convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Seperable convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Copy an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

#cosImage

Return the cosine of an image in degrees.

Returns:

  • (Image)

    cosine of each pixel



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

def cos
    math :cos
end

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

Count lines in an image.

Parameters:

  • direction (Vips::Direction)

    Countlines left-right or up-down

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Float)

    Number of lines



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

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

Save image to csv file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :separator (String)

    Separator characters

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Calculate de00.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Calculate de76.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Calculate decmc.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#deviate(opts = {}) ⇒ Float

Find image standard deviation.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Float)

    Output value



# 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.

Parameters:

  • mask (Image, Array<Real>, Array<Array<Real>>)

    structuring element

Returns:

  • (Image)

    dilated image



1235
1236
1237
# File 'lib/vips/image.rb', line 1235

def dilate(mask)
    morph mask, :dilate
end

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

Divide two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Draw a circle on an image.

Parameters:

  • ink (Array<Double>)

    Colour for pixels

  • cx (Integer)

    Centre of draw_circle

  • cy (Integer)

    Centre of draw_circle

  • radius (Integer)

    Radius in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :fill (Boolean)

    Draw a solid object

Returns:



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

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

Flood-fill an area.

Parameters:

  • ink (Array<Double>)

    Colour for pixels

  • x (Integer)

    DrawFlood start point

  • y (Integer)

    DrawFlood start point

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Image to draw on, Hash of optional output items



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

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

Paint an image into another image.

Parameters:

  • sub (Vips::Image)

    Sub-image to insert into main image

  • x (Integer)

    Draw image here

  • y (Integer)

    Draw image here

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :mode (Vips::CombineMode)

    Combining mode

Returns:



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

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

Draw a line on an image.

Parameters:

  • ink (Array<Double>)

    Colour for pixels

  • x1 (Integer)

    Start of draw_line

  • y1 (Integer)

    Start of draw_line

  • x2 (Integer)

    End of draw_line

  • y2 (Integer)

    End of draw_line

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Draw a mask on an image.

Parameters:

  • ink (Array<Double>)

    Colour for pixels

  • mask (Vips::Image)

    Mask of pixels to draw

  • x (Integer)

    Draw mask here

  • y (Integer)

    Draw mask here

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Paint a rectangle on an image.

Parameters:

  • ink (Array<Double>)

    Colour for pixels

  • left (Integer)

    Rect to fill

  • top (Integer)

    Rect to fill

  • width (Integer)

    Rect to fill

  • height (Integer)

    Rect to fill

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :fill (Boolean)

    Draw a solid object

Returns:



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

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

Blur a rectangle on an image.

Parameters:

  • left (Integer)

    Rect to fill

  • top (Integer)

    Rect to fill

  • width (Integer)

    Rect to fill

  • height (Integer)

    Rect to fill

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Save image to deepzoom file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :basename (String)

    Base name to save to

  • :layout (Vips::ForeignDzLayout)

    Directory layout

  • :suffix (String)

    Filename suffix for tiles

  • :overlap (Integer)

    Tile overlap in pixels

  • :tile_size (Integer)

    Tile size in pixels

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :centre (Boolean)

    Center image in tile

  • :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

Returns:

  • (nil)


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

#dzsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to dz buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :basename (String)

    Base name to save to

  • :layout (Vips::ForeignDzLayout)

    Directory layout

  • :suffix (String)

    Filename suffix for tiles

  • :overlap (Integer)

    Tile overlap in pixels

  • :tile_size (Integer)

    Tile size in pixels

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :centre (Boolean)

    Center image in tile

  • :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

Returns:

  • (Vips::Blob)

    Buffer to save to



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

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

Embed an image in a larger image.

Parameters:

  • x (Integer)

    Left edge of input in output

  • y (Integer)

    Top edge of input in output

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Colour for background pixels

Returns:



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

#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.

Parameters:

  • mask (Image, Array<Real>, Array<Array<Real>>)

    structuring element

Returns:

  • (Image)

    eroded image



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

def erode(mask)
    morph mask, :erode
end

#expImage

Return e ** pixel.

Returns:



1190
1191
1192
# File 'lib/vips/image.rb', line 1190

def exp
    math :exp
end

#exp10Image

Return 10 ** pixel.

Returns:

  • (Image)

    10 ** pixel



1197
1198
1199
# File 'lib/vips/image.rb', line 1197

def exp10
    math :exp10
end

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

Extract an area from an image.

Parameters:

  • 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

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Extract band from an image.

Parameters:

  • band (Integer)

    Band to extract

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :n (Integer)

    Number of bands to extract

Returns:



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

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

False-colour an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Fast correlation.

Parameters:

  • ref (Vips::Image)

    Input reference image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Save image to fits file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Flatten alpha out of an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :background (Array<Double>)

    Background value

  • :max_alpha (Float)

    Maximum value of alpha channel

Returns:



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

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

Flip an image.

Parameters:

  • direction (Vips::Direction)

    Direction to flip image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#fliphorImage

Flip horizontally.

Returns:

  • (Image)

    image flipped horizontally



1204
1205
1206
# File 'lib/vips/image.rb', line 1204

def fliphor
    flip :horizontal
end

#flipverImage

Flip vertically.

Returns:

  • (Image)

    image flipped vertically



1211
1212
1213
# File 'lib/vips/image.rb', line 1211

def flipver
    flip :vertical
end

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

Transform float rgb to radiance coding.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#floorImage

Return the largest integral value not greater than the argument.

Returns:

  • (Image)

    floor of image



977
978
979
# File 'lib/vips/image.rb', line 977

def floor
    round :floor
end

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

Frequency-domain filtering.

Parameters:

  • mask (Vips::Image)

    Input mask image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Forward fft.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Gamma an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :exponent (Float)

    Gamma factor

Returns:



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

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

Gaussian blur.

Parameters:

  • sigma (Float)

    Sigma of Gaussian

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :min_ampl (Float)

    Minimum amplitude of Gaussian

  • :precision (Vips::Precision)

    Convolve with this precision

Returns:



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

#get(name) ⇒ Integer, GValue

Fetch a GValue from an image. The return status is 0 for success, -1 for failure.

Parameters:

  • name (String)

    Metadata field to fetch

Returns:

  • (Integer, GValue)

    Return status, GValue from image

See Also:



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

#get_typeof(name) ⇒ Integer

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

Parameters:

  • name (String)

    Metadata field to fetch

Returns:

  • (Integer)

    GType

See Also:



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

#get_value(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_value "icc-profile-data"

and profile will be an array containing the profile.

Parameters:

  • name (String)

    Metadata field to set

Returns:

  • (Object)

    Value of field

See Also:



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

def get_value(name)
    ret, gval = get name
    if ret != 0
        raise Vips::Error, "Field #{name} not found."
    end
    value = gval.value

    Argument::unwrap(value)
end

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

Read a point from an image.

Parameters:

  • x (Integer)

    Point to read

  • y (Integer)

    Point to read

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Array<Double>)

    Array of output values



1062
1063
1064
1065
1066
1067
1068
1069
# File 'lib/vips/image.rb', line 1062

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.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :gamma (Float)

    Image gamma

  • :int_output (Boolean)

    Integer output

Returns:



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

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

Grid an image.

Parameters:

  • tile_height (Integer)

    chop into tiles this high

  • across (Integer)

    number of tiles across

  • down (Integer)

    number of tiles down

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Form cumulative histogram.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#hist_entropy(opts = {}) ⇒ Float

Estimate image entropy.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Float)

    Output value



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

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

Histogram equalisation.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :band (Integer)

    Equalise with this band

Returns:



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

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

Find image histogram.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :band (Integer)

    Find histogram of band

Returns:



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

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

Find indexed image histogram.

Parameters:

  • index (Vips::Image)

    Index image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Find n-dimensional image histogram.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :bins (Integer)

    Number of bins in each dimension

Returns:



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

#hist_ismonotonic(opts = {}) ⇒ Boolean

Test for monotonicity.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Boolean)

    true if in is monotonic



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

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

Local histogram equalisation.

Parameters:

  • width (Integer)

    Window width in pixels

  • height (Integer)

    Window height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :max_slope (Integer)

    Maximum slope (CLAHE)

Returns:



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

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

Match two histograms.

Parameters:

  • ref (Vips::Image)

    Reference histogram

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Normalise histogram.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Plot histogram.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Find hough circle transform.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Find hough line transform.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :width (Integer)

    horizontal size of parameter space

  • :height (Integer)

    Vertical size of parameter space

Returns:



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

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

Transform hsv to srgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Output to device with icc profile.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :intent (Vips::Intent)

    Rendering intent

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :output_profile (String)

    Filename to load output profile from

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

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

Import from device with icc profile.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :intent (Vips::Intent)

    Rendering intent

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :embedded (Boolean)

    Use embedded input profile, if available

  • :input_profile (String)

    Filename to load input profile from

Returns:



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

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

Transform between devices with icc profiles.

Parameters:

  • output_profile (String)

    Filename to load output profile from

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :intent (Vips::Intent)

    Rendering intent

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :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

Returns:



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

#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.

Parameters:

  • th (Image, Real, Array<Real>)

    true values

  • el (Image, Real, Array<Real>)

    false values

  • opts (Hash) (defaults to: {})

    set of options

Options Hash (opts):

  • :blend (Boolean) — default: false

    Blend smoothly between th and el

Returns:

  • (Image)

    merged image



1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
# File 'lib/vips/image.rb', line 1269

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

    if not th.is_a? Vips::Image
        th = Argument::imageize match_image, th
    end
    if not el.is_a? Vips::Image
        el = Argument::imageize match_image, el
    end

    Vips::call_base "ifthenelse", self, "", [th, el, opts]
end

#imagImage

Return the imaginary part of a complex image.

Returns:

  • (Image)

    imaginary part of complex image



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

def imag
    complexget :imag
end

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

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

Parameters:

  • sub (Vips::Image)

    Sub-image to insert into main image

  • x (Integer)

    Left edge of sub in main

  • y (Integer)

    Top edge of sub in main

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :background (Array<Double>)

    Colour for new pixels

Returns:



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

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

Invert an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Build an inverted look-up table.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :size (Integer)

    LUT size to generate

Returns:



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

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

Inverse fft.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :real (Boolean)

    Output only the real part of the transform

Returns:



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

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

Join a pair of images.

Parameters:

  • in2 (Vips::Image)

    Second input image

  • direction (Vips::Direction)

    Join left-right or up-down

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :align (Vips::Align)

    Align on the low, centre or high coordinate edge

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

Returns:



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

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

Save image to jpeg file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:

  • (nil)


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

#jpegsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to jpeg buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:

  • (Vips::Blob)

    Buffer to save to



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

#jpegsave_mime(opts = {}) ⇒ nil

Save image to jpeg mime.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:

  • (nil)


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

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

Transform float lab to labq coding.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform float lab to signed short.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform lab to lch.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform cielab to xyz.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :temp (Array<Double>)

    Colour temperature

Returns:



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

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

Label regions in an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :segments (Integer)

    Output Number of discrete contigious regions

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Mask of region labels, Hash of optional output items



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

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

Unpack a labq image to float lab.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Unpack a labq image to short lab.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Convert a labq image to srgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform signed short lab to float.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform short lab to labq coding.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform lch to cmc.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform lch to lab.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Calculate (a * in + b).

Parameters:

  • a (Array<Double>)

    Multiply by this

  • b (Array<Double>)

    Add this

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :uchar (Boolean)

    Output should be uchar

Returns:



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

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

Cache an image as a set of lines.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

#logImage

Return the natural log of an image.

Returns:

  • (Image)

    natural log of each pixel



1176
1177
1178
# File 'lib/vips/image.rb', line 1176

def log
    math :log
end

#log10Image

Return the log base 10 of an image.

Returns:

  • (Image)

    base 10 log of each pixel



1183
1184
1185
# File 'lib/vips/image.rb', line 1183

def log10
    math :log10
end

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

Resample with an mapim image.

Parameters:

  • index (Vips::Image)

    Index pixels with this

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

Returns:



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

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

Map an image though a lut.

Parameters:

  • lut (Vips::Image)

    Look-up table image

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :band (Integer)

    apply one-band lut to this band of in

Returns:



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

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

First-order match of two images.

Parameters:

  • sec (Vips::Image)

    Secondary image

  • xr1 (Integer)

    Position of first reference tie-point

  • yr1 (Integer)

    Position of first reference tie-point

  • xs1 (Integer)

    Position of first secondary tie-point

  • ys1 (Integer)

    Position of first secondary tie-point

  • xr2 (Integer)

    Position of second reference tie-point

  • yr2 (Integer)

    Position of second reference tie-point

  • xs2 (Integer)

    Position of second secondary tie-point

  • ys2 (Integer)

    Position of second secondary tie-point

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Apply a math operation to an image.

Parameters:

  • math (Vips::OperationMath)

    math to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Binary math operations.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • math2 (Vips::OperationMath2)

    math to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Binary math operations with a constant.

Parameters:

  • c (Array<Double>)

    Array of constants

  • math2 (Vips::OperationMath2)

    math to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#matrixprint(opts = {}) ⇒ nil

Print matrix.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Save image to matrix file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Find image maximum.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:

  • (Float, Hash<Symbol => Object>)

    Output value, Hash of optional output items



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

#maxposReal

Return the coordinates of the image maximum.

Returns:

  • (Real, Real, Real)

    maximum value, x coordinate of maximum, y coordinate of maximum



1039
1040
1041
1042
1043
1044
# File 'lib/vips/image.rb', line 1039

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 colour chart.

Parameters:

  • h (Integer)

    Number of patches across chart

  • v (Integer)

    Number of patches down chart

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

#median(size = 3) ⇒ Image

a median filter

Parameters:

  • size (Integer) (defaults to: 3)

    size of filter window

Returns:

  • (Image)

    result of median filter



1075
1076
1077
# File 'lib/vips/image.rb', line 1075

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

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

Merge two images.

Parameters:

  • sec (Vips::Image)

    Secondary image

  • direction (Vips::Direction)

    Horizontal or vertcial merge

  • dx (Integer)

    Horizontal displacement from sec to ref

  • dy (Integer)

    Vertical displacement from sec to ref

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :mblend (Integer)

    Maximum blend size

Returns:



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

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

Find image minimum.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:

  • (Float, Hash<Symbol => Object>)

    Output value, Hash of optional output items



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

#minposReal

Return the coordinates of the image minimum.

Returns:

  • (Real, Real, Real)

    minimum value, x coordinate of minimum, y coordinate of minimum



1050
1051
1052
1053
1054
1055
# File 'lib/vips/image.rb', line 1050

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.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • morph (Vips::OperationMorphology)

    Morphological operation to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Mosaic two images.

Parameters:

  • sec (Vips::Image)

    Secondary image

  • direction (Vips::Direction)

    Horizontal or vertcial mosaic

  • xref (Integer)

    Position of reference tie-point

  • yref (Integer)

    Position of reference tie-point

  • xsec (Integer)

    Position of secondary tie-point

  • ysec (Integer)

    Position of secondary tie-point

  • opts (Hash) (defaults to: {})

    Set of options

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

  • :dx1 (Float)

    Output Detected first-order displacement

  • :dy1 (Float)

    Output Detected first-order displacement

Returns:

  • (Vips::Image, Hash<Symbol => Object>)

    Output image, Hash of optional output items



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

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

First-order mosaic of two images.

Parameters:

  • sec (Vips::Image)

    Secondary image

  • direction (Vips::Direction)

    Horizontal or vertcial mosaic

  • xr1 (Integer)

    Position of first reference tie-point

  • yr1 (Integer)

    Position of first reference tie-point

  • xs1 (Integer)

    Position of first secondary tie-point

  • ys1 (Integer)

    Position of first secondary tie-point

  • xr2 (Integer)

    Position of second reference tie-point

  • yr2 (Integer)

    Position of second reference tie-point

  • xs2 (Integer)

    Position of second secondary tie-point

  • ys2 (Integer)

    Position of second secondary tie-point

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Pick most-significant byte from an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :band (Integer)

    Band to msb

Returns:



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

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

Multiply two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Find threshold for percent of pixels.

Parameters:

  • percent (Float)

    Percent of pixels

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Integer)

    Threshold above which lie percent of pixels



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

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

Calculate phase correlation.

Parameters:

  • in2 (Vips::Image)

    Second input image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Save image to png file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :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

Returns:

  • (nil)


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

#pngsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to png buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :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

Returns:

  • (Vips::Blob)

    Buffer to save to



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

#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.

Returns:

  • (Image)

    image converted to polar coordinates

See Also:



1102
1103
1104
# File 'lib/vips/image.rb', line 1102

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

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

Save image to ppm file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :ascii (Boolean)

    save as ascii

  • :squash (Boolean)

    save as one bit

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Premultiply image alpha.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :max_alpha (Float)

    Maximum value of alpha channel

Returns:



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

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

Find image profiles.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Array<] First non-zero pixel in column, First non-zero pixel in row)

    Array<] First non-zero pixel in column, First non-zero pixel in row



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

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

Find image projections.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:

  • (Array<] Sums of columns, Sums of rows)

    Array<] Sums of columns, Sums of rows



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

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

Resample an image with a quadratic transform.

Parameters:

  • coeff (Vips::Image)

    Coefficient matrix

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

Returns:



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

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

Unpack radiance coding to float rgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Save image to radiance file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

#radsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to radiance buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (Vips::Blob)

    Buffer to save to



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

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

Rank filter.

Parameters:

  • width (Integer)

    Window width in pixels

  • height (Integer)

    Window height in pixels

  • index (Integer)

    Select pixel at index

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Save image to raw file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Write raw image to file descriptor.

Parameters:

  • fd (Integer)

    File descriptor to write to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

#realImage

Return the real part of a complex image.

Returns:

  • (Image)

    real part of complex image



1082
1083
1084
# File 'lib/vips/image.rb', line 1082

def real
    complexget :real
end

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

Linear recombination with matrix.

Parameters:

  • m (Vips::Image)

    matrix of coefficients

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#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.

Returns:

  • (Image)

    image converted to rectangular coordinates

See Also:



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

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

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

Reduce an image.

Parameters:

  • hshrink (Float)

    Horizontal shrink factor

  • vshrink (Float)

    Vertical shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention

Returns:



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

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

Shrink an image horizontally.

Parameters:

  • hshrink (Float)

    Horizontal shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention

Returns:



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

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

Shrink an image vertically.

Parameters:

  • vshrink (Float)

    Vertical shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention

Returns:



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

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

Relational operation on two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • relational (Vips::OperationRelational)

    relational to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Relational operations against a constant.

Parameters:

  • c (Array<Double>)

    Array of constants

  • relational (Vips::OperationRelational)

    relational to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Remainder after integer division of two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Remainder after integer division of an image and a constant.

Parameters:

  • c (Array<Double>)

    Array of constants

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Replicate an image.

Parameters:

  • across (Integer)

    Repeat this many times horizontally

  • down (Integer)

    Repeat this many times vertically

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Resize an image.

Parameters:

  • scale (Float)

    Scale image by this factor

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :centre (Boolean)

    Use centre sampling convention

  • :vscale (Float)

    Vertical scale image by this factor

Returns:



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

#rintImage

Return the nearest integral value.

Returns:

  • (Image)

    rint of image



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

def rint
    round :rint
end

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

Rotate an image.

Parameters:

  • angle (Vips::Angle)

    Angle to rotate image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#rot180Image

Rotate by 180 degrees clockwise.

Returns:

  • (Image)

    rotated image



1249
1250
1251
# File 'lib/vips/image.rb', line 1249

def rot180
    rot :d180
end

#rot270Image

Rotate by 270 degrees clockwise.

Returns:

  • (Image)

    rotated image



1256
1257
1258
# File 'lib/vips/image.rb', line 1256

def rot270
    rot :d270
end

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

Rotate an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

Returns:



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

#rot90Image

Rotate by 90 degrees clockwise.

Returns:

  • (Image)

    rotated image



1242
1243
1244
# File 'lib/vips/image.rb', line 1242

def rot90
    rot :d90
end

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

Perform a round function on an image.

Parameters:

  • round (Vips::OperationRound)

    rounding operation to perform

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Scale an image to uchar.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :log (Boolean)

    Log scale

  • :exp (Float)

    Exponent for log scale

Returns:



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

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

Convert scrgb to bw.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

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

Convert an scrgb image to srgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

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

Transform scrgb to xyz.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Check sequential access.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :trace (Boolean)

    trace pixel requests

  • :tile_height (Integer)

    Tile height in pixels

  • :access (Vips::Access)

    Expected access pattern

Returns:



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

#set(name, value) ⇒ Object

Set a GValue on an image

Parameters:

  • name (String)

    Metadata field to set

  • value (GValue)

    GValue to set

See Also:



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

#set_value(name, value) ⇒ Object

Set a metadata item on an image. 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_value "icc-profile-data", profile

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

Parameters:

  • name (String)

    Metadata field to set

  • value (Object)

    Value to set

See Also:



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
# File 'lib/vips/image.rb', line 722

def set_value(name, value)
    gtype = get_typeof name
    if gtype != 0
        # array-ize
        value = Argument::arrayize gtype, value

        # blob-ize
        if gtype.type_is_a? GLib::Type["VipsBlob"]
            if not value.is_a? Vips::Blob
                value = Vips::Blob.copy value
            end
        end

        # image-ize
        if gtype.type_is_a? GLib::Type["VipsImage"]
            if not value.is_a? Vips::Image
                value = imageize match_image, value
            end
        end

    end

    set name, value
end

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

Unsharp masking for print.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

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

Shrink an image.

Parameters:

  • hshrink (Float)

    Horizontal shrink factor

  • vshrink (Float)

    Vertical shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Shrink an image horizontally.

Parameters:

  • hshrink (Integer)

    Horizontal shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Shrink an image vertically.

Parameters:

  • vshrink (Integer)

    Vertical shrink factor

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Unit vector of pixel.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Similarity transform of an image.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:



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

#sinImage

Return the sine of an image in degrees.

Returns:

  • (Image)

    sine of each pixel



1134
1135
1136
# File 'lib/vips/image.rb', line 1134

def sin
    math :sin 
end

#sizeInteger

Get the image size.

Returns:

  • (Integer, Integer)

    image width and height



750
751
752
# File 'lib/vips/image.rb', line 750

def size
    [width, height]
end

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

Spatial correlation.

Parameters:

  • ref (Vips::Image)

    Input reference image

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Make displayable power spectrum.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform srgb to hsv.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Convert an srgb image to scrgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Find image average.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Statistical difference.

Parameters:

  • width (Integer)

    Window width in pixels

  • height (Integer)

    Window height in pixels

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :a (Float)

    Weight of new mean

  • :m0 (Float)

    New mean

  • :b (Float)

    Weight of new deviation

  • :s0 (Float)

    New deviation

Returns:



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

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

Subsample an image.

Parameters:

  • xfac (Integer)

    Horizontal subsample factor

  • yfac (Integer)

    Vertical subsample factor

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :point (Boolean)

    Point sample

Returns:



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

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

Subtract two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#tanImage

Return the tangent of an image in degrees.

Returns:

  • (Image)

    tangent of each pixel



1148
1149
1150
# File 'lib/vips/image.rb', line 1148

def tan
    math :tan
end

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

Save image to tiff file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

  • :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

  • :squash (Boolean)

    Squash images down to 1 bit

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :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

Returns:

  • (nil)


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

#tiffsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to tiff buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

  • :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

  • :squash (Boolean)

    Squash images down to 1 bit

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :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

Returns:

  • (Vips::Blob)

    Buffer to save to



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

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

Cache an image as a set of tiles.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

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

Returns:



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

#to_aArray

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

Returns:

  • (Array)

    array of Fixnum



962
963
964
965
966
967
968
969
970
971
972
# File 'lib/vips/image.rb', line 962

def to_a
    ar = Array.new(height)
    for y in 0...height
        ar[y] = Array.new(width)
            for x in 0...width
                ar[y][x] = getpoint(x, y)
            end
    end

    return ar
end

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

Unpremultiply image alpha.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :max_alpha (Float)

    Maximum value of alpha channel

Returns:



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

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

Save image to vips file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

Returns:

  • (nil)


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

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

Save image to webp file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:

  • (nil)


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

#webpsave_buffer(opts = {}) ⇒ Vips::Blob

Save image to webp buffer.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :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

Returns:

  • (Vips::Blob)

    Buffer to save to



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

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

Wrap image origin.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :x (Integer)

    Left edge of input in output

  • :y (Integer)

    Top edge of input in output

Returns:



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

#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.

Parameters:

  • format_string (String)

    save format plus options

  • opts (Hash) (defaults to: {})

    set of options

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

Returns:

  • (String)

    the image saved in the specified format



626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/vips/image.rb', line 626

def write_to_buffer(format_string, opts = {})
    filename = Vips::filename_get_filename format_string
    option_string = Vips::filename_get_options format_string
    saver = Vips::Foreign.find_save_buffer filename
    if saver == nil
        raise Vips::Error, "No known saver for '#{filename}'."
    end

    buffer = Vips::call_base saver, self, option_string, [opts]

    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.

Parameters:

  • opts (Hash) (defaults to: {})

    set of options

  • name (String)

    filename to write to

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



588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/vips/image.rb', line 588

def write_to_file(name, opts = {})
    filename = Vips::filename_get_filename name
    option_string = Vips::filename_get_options name
    saver = Vips::Foreign.find_save filename
    if saver == nil
        raise Vips::Error, "No known saver for '#{filename}'."
    end

    Vips::call_base saver, self, option_string, [filename, opts]

    write_gc
end

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

Transform xyz to lab.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Options Hash (opts):

  • :temp (Array<Double>)

    Colour temperature

Returns:



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

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

Transform xyz to scrgb.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform xyz to yxy.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Transform yxy to xyz.

Parameters:

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

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

Zoom an image.

Parameters:

  • xfac (Integer)

    Horizontal zoom factor

  • yfac (Integer)

    Vertical zoom factor

  • opts (Hash) (defaults to: {})

    Set of options

Returns:



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

#|(other) ⇒ Image

Integer bitwise OR with an image, constant or array.

Parameters:

  • other (Image, Real, Array<Real>)

    bitwise OR with this

Returns:

  • (Image)

    result of bitwise OR



828
829
830
831
# File 'lib/vips/image.rb', line 828

def |(other)
    other.is_a?(Vips::Image) ? 
        boolean(other, :or) : boolean_const(other, :or)
end

#~Image

Equivalent to image ^ -1

Returns:

  • (Image)

    image with bits flipped



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

def ~
    self ^ -1
end