Class: Vips::Image

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

Overview

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

Defined Under Namespace

Modules: ImageLayout Classes: GenericPtr, ManagedStruct, Struct

Instance Attribute Summary

Attributes inherited from GObject::GObject

#ptr, #references

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#get_pspec, #get_typeof_error, print_all, #signal_connect

Methods inherited from GObject::GObject

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

Constructor Details

This class inherits a constructor from GObject::GObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

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

Parameters:

  • name (String)

    vips operation to call

Returns:

  • result of vips operation



206
207
208
# File 'lib/vips/image.rb', line 206

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

Class Method Details

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

Load an analyze6 image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.arrayjoin(im, **opts) ⇒ Vips::Image

Join an array of images.

Parameters:

  • im (Array<Image>)

    Array of input images

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :across (Integer)

    Number of images across grid

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :halign (Vips::Align)

    Align on the left, centre or right

  • :valign (Vips::Align)

    Align on the top, centre or bottom

  • :hspacing (Integer)

    Horizontal spacing between images

  • :vspacing (Integer)

    Vertical spacing between images

Returns:



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

.bandrank(im, **opts) ⇒ Vips::Image

Band-wise rank of a set of images.

Parameters:

  • im (Array<Image>)

    Array of input images

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :index (Integer)

    Select this band element from sorted list

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :bands (Integer)

    Number of bands in image

Returns:



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

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

Load csv.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :skip (Integer)

    Skip this many lines at the start of the file

  • :lines (Integer)

    Read this many lines from the file

  • :whitespace (String)

    Set of whitespace characters

  • :separator (String)

    Set of separator characters

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.csvload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load csv.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :skip (Integer)

    Skip this many lines at the start of the file

  • :lines (Integer)

    Read this many lines from the file

  • :whitespace (String)

    Set of whitespace characters

  • :separator (String)

    Set of separator characters

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    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 634

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

Load a fits image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.fitsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load fits from a source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Returns:



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

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

    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 600

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

    Set of options

Options Hash (**opts):

  • :sigma (Float)

    Standard deviation of pixels in generated image

  • :mean (Float)

    Mean of pixels in generated image

  • :seed (Integer)

    Random number seed

Returns:



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

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

Load gif with libnsgif.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :n (Integer)

    Load this many pages

  • :page (Integer)

    Load this page from the file

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load gif with libnsgif.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :n (Integer)

    Load this many pages

  • :page (Integer)

    Load this page from the file

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.gifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load gif from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :n (Integer)

    Load this many pages

  • :page (Integer)

    Load this page from the file

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

Returns:



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

.heifload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load a heif image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :thumbnail (Boolean)

    Fetch thumbnail image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.heifload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load a heif image.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :thumbnail (Boolean)

    Fetch thumbnail image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.heifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load a heif image.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :thumbnail (Boolean)

    Fetch thumbnail image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.identity(**opts) ⇒ Vips::Image

Make a 1d image where pixel values are indexes.

Parameters:

  • opts (Hash)

    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 833

.jp2kload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg2000 image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jp2kload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg2000 image.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jp2kload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg2000 image.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load jpeg from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load jpeg from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jpegload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load image from jpeg source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jxlload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg-xl image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jxlload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg-xl image.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.jxlload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load jpeg-xl image.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    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 609

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

Load file with imagemagick.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    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

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load buffer with imagemagick.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    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

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space

Returns:



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

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

Load mat from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.matrix_from_array(width, height, array) ⇒ Object



442
443
444
445
446
447
448
# File 'lib/vips/image.rb', line 442

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

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

Load matrix.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.matrixload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load matrix.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Invoke a vips operation with Operation.call.



211
212
213
# File 'lib/vips/image.rb', line 211

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

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

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

For example:

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

or

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

Raises:



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/vips/image.rb', line 476

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

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

    array = array.flatten
  else
    height = 1
    width = array.length
  end

  unless array.length == width * height
    raise Vips::Error, "Bad array dimensions."
  end

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

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

  image.mutate do |mutable|
    # be careful to set them as double
    mutable.set_type! GObject::GDOUBLE_TYPE, "scale", scale.to_f
    mutable.set_type! GObject::GDOUBLE_TYPE, "offset", offset.to_f
  end
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 binary string. Load options may be passed as strings or appended as a hash. For example:

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

or alternatively:

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

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

$ vips jpegload_buffer

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

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

Parameters:

  • data (String)

    the data to load from

  • option_string (String)

    load options as a string

  • opts (Hash)

    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

Raises:



295
296
297
298
299
300
# File 'lib/vips/image.rb', line 295

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

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

.new_from_file(name, **opts) ⇒ Image

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

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

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

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

    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

Raises:



251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/vips/image.rb', line 251

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

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

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

.new_from_memory(data, width, height, bands, format) ⇒ Image

Create a new Vips::Image from a C-style array held in memory. For example:

image = Vips::Image.black(16, 16) + 128
data = image.write_to_memory

x = Vips::Image.new_from_memory data,
  image.width, image.height, image.bands, image.format

Creating a new image from a memory pointer:

ptr = FFI::MemoryPointer.new(:uchar, 10*10)
# => #<FFI::MemoryPointer address=0x00007fc236db31d0 size=100>
x = Vips::Image.new_from_memory(ptr, 10, 10, 1, :uchar)

Creating a new image from an address only pointer:

ptr = call_to_external_c_library(w: 10, h: 10)
# => #<FFI::Pointer address=0x00007f9780813a00>
ptr_slice = ptr.slice(0, 10*10)
# => #<FFI::Pointer address=0x00007f9780813a00 size=100>
x = Vips::Image.new_from_memory(ptr_slice, 10, 10, 1, :uchar)

new_from_memory keeps a reference to the array of pixels you pass in to try to prevent that memory from being freed by the Ruby GC while it is being used.

See new_from_memory_copy for a version of this method which does not keep a reference.

Parameters:

  • data (String, FFI::Pointer)

    the data to load from

  • width (Integer)

    width in pixels

  • height (Integer)

    height in pixels

  • bands (Integer)

    number of bands

  • format (Symbol)

    band format

Returns:

  • (Image)

    the loaded image

Raises:



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

def self.new_from_memory data, width, height, bands, format
  # prevent data from being freed with JRuby FFI
  if defined?(JRUBY_VERSION) && !data.is_a?(FFI::Pointer)
    data = ::FFI::MemoryPointer.new(:char, data.bytesize).write_bytes data
  end

  if data.is_a?(FFI::Pointer)
    # A pointer needs to know about the size of the memory it points to.
    # If you have an address-only pointer, use the .slice method to wrap
    # the pointer in a size aware pointer.
    if data.size == UNKNOWN_POINTER_SIZE
      raise Vips::Error, "size of memory is unknown"
    end
    size = data.size
  else
    size = data.bytesize
  end

  format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format
  vi = Vips.vips_image_new_from_memory data, size,
    width, height, bands, format_number
  raise Vips::Error if vi.null?
  image = new(vi)

  # keep a secret ref to the underlying object .. this reference will be
  # inherited by things that in turn depend on us, so the memory we are
  # using will not be freed
  image.references << data

  image
end

.new_from_memory_copy(data, width, height, bands, format) ⇒ Image

Create a new Vips::Image from memory and copies the memory area. See new_from_memory for a version of this method which does not copy the memory area.

Parameters:

  • data (String, FFI::Pointer)

    the data to load from

  • width (Integer)

    width in pixels

  • height (Integer)

    height in pixels

  • bands (Integer)

    number of bands

  • format (Symbol)

    band format

Returns:

  • (Image)

    the loaded image

Raises:



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/vips/image.rb', line 385

def self.new_from_memory_copy data, width, height, bands, format
  format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format

  if data.is_a?(FFI::Pointer)
    if data.size == UNKNOWN_POINTER_SIZE
      raise Vips::Error, "size of memory is unknown"
    end
    size = data.size
  else
    size = data.bytesize
  end

  vi = Vips.vips_image_new_from_memory_copy data, size,
    width, height, bands, format_number
  raise Vips::Error if vi.null?
  new(vi)
end

.new_from_source(source, option_string, **opts) ⇒ Image

Create a new Vips::Image from a source. Load options may be passed as strings or appended as a hash. For example:

source = Vips::Source.new_from_file("k2.jpg")
image = Vips::Image.new_from_source source, "shrink=2"

or alternatively:

image = Vips::Image.new_from_source source, "", shrink: 2

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

$ vips jpegload_source

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

Loading is fast: only enough data is read to be able to fill out the header. Pixels will only be read and decompressed when they are needed.

Parameters:

  • source (Vips::Source)

    the source to load from

  • option_string (String)

    load options as a string

  • opts (Hash)

    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

Raises:



435
436
437
438
439
440
# File 'lib/vips/image.rb', line 435

def self.new_from_source source, option_string, **opts
  loader = Vips.vips_foreign_find_load_source source
  raise Vips::Error if loader.nil?

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

.niftiload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load nifti volume.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.niftiload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load nifti volumes.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load an openexr image.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load file with openslide.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :attach_associated (Boolean)

    Attach all associated images

  • :level (Integer)

    Load this level from the file

  • :autocrop (Boolean)

    Crop to image bounds

  • :associated (String)

    Load this associated image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.openslideload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load source with openslide.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :attach_associated (Boolean)

    Attach all associated images

  • :level (Integer)

    Load this level from the file

  • :autocrop (Boolean)

    Crop to image bounds

  • :associated (String)

    Load this associated image

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load pdf from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :background (Array<Double>)

    Background value

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load pdf from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :background (Array<Double>)

    Background value

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.pdfload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load pdf from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :background (Array<Double>)

    Background value

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Options Hash (**opts):

  • :cell_size (Integer)

    Size of Perlin cells

  • :uchar (Boolean)

    Output an unsigned char image

  • :seed (Integer)

    Random number seed

Returns:



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

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

Load png from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :unlimited (Boolean)

    Remove all denial of service limits

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load png from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :unlimited (Boolean)

    Remove all denial of service limits

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.pngload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load png from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :unlimited (Boolean)

    Remove all denial of service limits

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load ppm from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.ppmload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load ppm base class.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.profile_load(name, **opts) ⇒ VipsBlob

Load named icc profile.

Parameters:

  • name (String)

    Profile name

  • opts (Hash)

    Set of options

Returns:

  • (VipsBlob)

    Loaded profile



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

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

Load a radiance image from a file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.radload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load rad from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.radload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load rad from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Options Hash (**opts):

  • :offset (guint64)

    Offset in bytes from start of file

  • :format (Vips::BandFormat)

    Pixel format in image

  • :interpretation (Vips::Interpretation)

    Pixel interpretation

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Returns:

  • (Boolean)


194
195
196
197
198
199
# File 'lib/vips/image.rb', line 194

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

  super
end

.sines(width, height, **opts) ⇒ Vips::Image

Make a 2d sine wave.

Parameters:

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash)

    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 659

.sum(im, **opts) ⇒ Vips::Image

Sum an array of images.

Parameters:

  • im (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)

    Set of options

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load svg with rsvg.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.svgload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load svg from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.switch(tests, **opts) ⇒ Vips::Image

Find the index of the first non-zero pixel in tests.

Parameters:

  • tests (Array<Image>)

    Table of images to test

  • opts (Hash)

    Set of options

Returns:



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

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

Run an external command.

Parameters:

  • cmd_format (String)

    Command to run

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :im (Array<Image>)

    Array of input images

  • :out_format (String)

    Format for output filename

  • :in_format (String)

    Format for input filename

  • :out (Vips::Image)

    Output Output image

  • :log (String)

    Output Command log

Returns:

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

    Hash of optional output items



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

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

Make a text image.

Parameters:

  • text (String)

    Text to render

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :font (String)

    Font to render with

  • :width (Integer)

    Maximum image width in pixels

  • :height (Integer)

    Maximum image height in pixels

  • :align (Vips::Align)

    Align on the low, centre or high edge

  • :rgba (Boolean)

    Enable RGBA output

  • :dpi (Integer)

    DPI to render at

  • :justify (Boolean)

    Justify lines

  • :spacing (Integer)

    Line spacing

  • :fontfile (String)

    Load this font file

  • :autofit_dpi (Integer)

    Output DPI selected by autofit

Returns:

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

    Output image, Hash of optional output items



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

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

    Set of options

Options Hash (**opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :no_rotate (Boolean)

    Don't use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent

Returns:



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

.thumbnail_buffer(buffer, width, **opts) ⇒ Vips::Image

Generate thumbnail from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • width (Integer)

    Size to this width

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :option_string (String)

    Options that are passed on to the underlying loader

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :no_rotate (Boolean)

    Don't use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent

Returns:



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

.thumbnail_source(source, width, **opts) ⇒ Vips::Image

Generate thumbnail from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • width (Integer)

    Size to this width

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :option_string (String)

    Options that are passed on to the underlying loader

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :no_rotate (Boolean)

    Don't use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent

Returns:



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

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

Load tiff from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :subifd (Integer)

    Select subifd index

  • :n (Integer)

    Load this many pages

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load tiff from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :subifd (Integer)

    Select subifd index

  • :n (Integer)

    Load this many pages

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.tiffload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load tiff from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :subifd (Integer)

    Select subifd index

  • :n (Integer)

    Load this many pages

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.tonelut(**opts) ⇒ Vips::Image

Build a look-up table.

Parameters:

  • opts (Hash)

    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 818

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

Load vips from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.vipsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load vips from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load webp from file.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :scale (Float)

    Scale factor on load

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

Load webp from buffer.

Parameters:

  • buffer (VipsBlob)

    Buffer to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :scale (Float)

    Scale factor on load

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

.webpload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>

Load webp from source.

Parameters:

  • source (Vips::Source)

    Source to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page (Integer)

    Load this page from the file

  • :n (Integer)

    Load this many pages

  • :scale (Float)

    Scale factor on load

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

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

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

    Set of options

Options Hash (**opts):

  • :cell_size (Integer)

    Size of Worley cells

  • :seed (Integer)

    Random number seed

Returns:



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

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

    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 590

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

    Set of options

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

Returns:



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

Instance Method Details

#!Image

Equivalent to image ^ -1

Returns:

  • (Image)

    image with bits flipped



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

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



1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/vips/image.rb', line 1150

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

#%(other) ⇒ Image

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

Parameters:

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

    self modulo this

Returns:

  • (Image)

    result of modulo



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

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



1061
1062
1063
# File 'lib/vips/image.rb', line 1061

def & other
  call_enum "boolean", 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



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

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



1029
1030
1031
# File 'lib/vips/image.rb', line 1029

def ** other
  call_enum "math2", 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



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

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

#+@Image

Returns image.

Returns:



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

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



993
994
995
996
# File 'lib/vips/image.rb', line 993

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



1095
1096
1097
# File 'lib/vips/image.rb', line 1095

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



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

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



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

def < other
  call_enum "relational", 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



1037
1038
1039
# File 'lib/vips/image.rb', line 1037

def << other
  call_enum "boolean", 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



1112
1113
1114
# File 'lib/vips/image.rb', line 1112

def <= other
  call_enum "relational", 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



1137
1138
1139
1140
1141
1142
1143
1144
# File 'lib/vips/image.rb', line 1137

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

#>(other) ⇒ Image

Relational more than with an image, constant or array.

Parameters:

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

    relational more than with this

Returns:

  • (Image)

    result of more than



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

def > other
  call_enum "relational", 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



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

def >= other
  call_enum "relational", 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



1045
1046
1047
# File 'lib/vips/image.rb', line 1045

def >> other
  call_enum "boolean", 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)



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
# File 'lib/vips/image.rb', line 1163

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

#^(other) ⇒ Image

Integer bitwise EOR with an image, constant or array.

Parameters:

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

    bitwise EOR with this

Returns:

  • (Image)

    result of bitwise EOR



1069
1070
1071
# File 'lib/vips/image.rb', line 1069

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

#abs(**opts) ⇒ Vips::Image

Absolute value of an image.

Parameters:

  • opts (Hash)

    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



1425
1426
1427
# File 'lib/vips/image.rb', line 1425

def acos
  math :acos
end

#acoshImage

Return the inverse hyperbolic cosine of an image in radians.

Returns:

  • (Image)

    inverse cosine of each pixel



1467
1468
1469
# File 'lib/vips/image.rb', line 1467

def acosh
  math :acosh
end

#add(right, **opts) ⇒ Vips::Image

Add two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash)

    Set of options

Returns:



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

#add_alphaImage

Append an alpha channel to an image.

Returns:

Raises:



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

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

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

#affine(matrix, **opts) ⇒ Vips::Image

Affine transform of an image.

Parameters:

  • matrix (Array<Double>)

    Transformation matrix

  • opts (Hash)

    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

  • :background (Array<Double>)

    Background value

  • :premultiplied (Boolean)

    Images have premultiplied alpha

  • :extend (Vips::Extend)

    How to generate the extra pixels

Returns:



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

#asinImage

Return the inverse sine of an image in degrees.

Returns:

  • (Image)

    inverse sine of each pixel



1418
1419
1420
# File 'lib/vips/image.rb', line 1418

def asin
  math :asin
end

#asinhImage

Return the inverse hyperbolic sine of an image in radians.

Returns:

  • (Image)

    inverse sine of each pixel



1460
1461
1462
# File 'lib/vips/image.rb', line 1460

def asinh
  math :asinh
end

#atanImage

Return the inverse tangent of an image in degrees.

Returns:

  • (Image)

    inverse tangent of each pixel



1432
1433
1434
# File 'lib/vips/image.rb', line 1432

def atan
  math :atan
end

#atanhImage

Return the inverse hyperbolic tangent of an image in radians.

Returns:

  • (Image)

    inverse tangent of each pixel



1474
1475
1476
# File 'lib/vips/image.rb', line 1474

def atanh
  math :atanh
end

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

Autorotate image by exif tag.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :angle (Vips::Angle)

    Output Angle image was rotated by

  • :flip (Boolean)

    Output Whether the image was flipped or not

Returns:

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

    Output image, Hash of optional output items



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

#avg(**opts) ⇒ Float

Find image average.

Parameters:

  • opts (Hash)

    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



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

def bandand
  bandbool :and
end

#bandbool(boolean, **opts) ⇒ Vips::Image

Boolean operation across image bands.

Parameters:

Returns:



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

#bandeorImage

EOR the bands of an image together

Returns:

  • (Image)

    all bands EORed together



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

def bandeor
  bandbool :eor
end

#bandfold(**opts) ⇒ Vips::Image

Fold up x axis into bands.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :factor (Integer)

    Fold by this factor

Returns:



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

#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



1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
# File 'lib/vips/image.rb', line 1263

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

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

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

#bandjoin_const(c, **opts) ⇒ Vips::Image

Append a constant band to an image.

Parameters:

  • c (Array<Double>)

    Array of constants to add

  • opts (Hash)

    Set of options

Returns:



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

#bandmean(**opts) ⇒ Vips::Image

Band-wise average.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#bandorImage

OR the bands of an image together

Returns:

  • (Image)

    all bands ORed together



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

def bandor
  bandbool :or
end

#bandsInteger

Get number of image bands.

Returns:

  • (Integer)

    number of image bands



851
852
853
# File 'lib/vips/image.rb', line 851

def bands
  Vips.vips_image_get_bands self
end

#bandsplitArray<Image>

Split an n-band image into n separate images.

Returns:

  • (Array<Image>)

    Array of n one-band images



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

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

#bandunfold(**opts) ⇒ Vips::Image

Unfold image bands into x axis.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :factor (Integer)

    Unfold by this factor

Returns:



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

#boolean(right, boolean, **opts) ⇒ Vips::Image

Boolean operation on two images.

Parameters:

Returns:



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

#boolean_const(boolean, c, **opts) ⇒ Vips::Image

Boolean operations against a constant.

Parameters:

  • boolean (Vips::OperationBoolean)

    boolean to perform

  • c (Array<Double>)

    Array of constants

  • opts (Hash)

    Set of options

Returns:



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

#buildlut(**opts) ⇒ Vips::Image

Build a look-up table.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#byteswap(**opts) ⇒ Vips::Image

Byteswap an image.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#cache(**opts) ⇒ Vips::Image

Cache an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :max_tiles (Integer)

    Maximum number of tiles to cache

  • :tile_height (Integer)

    Tile height in pixels

  • :tile_width (Integer)

    Tile width in pixels

Returns:



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

#canny(**opts) ⇒ Vips::Image

Canny edge detector.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :sigma (Float)

    Sigma of Gaussian

  • :precision (Vips::Precision)

    Convolve with this precision

Returns:



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

#case(cases, **opts) ⇒ Vips::Image

Use pixel values to pick cases from an array of images.

Parameters:

  • cases (Array<Image>)

    Array of case images

  • opts (Hash)

    Set of options

Returns:



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

#cast(format, **opts) ⇒ Vips::Image

Cast an image.

Parameters:

  • format (Vips::BandFormat)

    Format to cast to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :shift (Boolean)

    Shift integer values up and down

Returns:



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

#ceilImage

Return the smallest integral value not less than the argument.

Returns:

  • (Image)

    ceil of image



1220
1221
1222
# File 'lib/vips/image.rb', line 1220

def ceil
  round :ceil
end

#closeObject



83
84
85
# File 'lib/vips/image.rb', line 83

def close
  Vips.vips_image_invalidate_all(self)
end

#CMC2LCh(**opts) ⇒ Vips::Image

Transform lch to cmc.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#CMYK2XYZ(**opts) ⇒ Vips::Image

Transform cmyk to xyz.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#codingSymbol

Get image coding.

Returns:

  • (Symbol)

    image coding



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

def coding
  get "coding"
end

#colourspace(space, **opts) ⇒ Vips::Image

Convert to a new colorspace.

Parameters:

Options Hash (**opts):

Returns:



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

#compass(mask, **opts) ⇒ Vips::Image

Convolve with rotating mask.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    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 2594

#complex(cmplx, **opts) ⇒ Vips::Image

Perform a complex operation on an image.

Parameters:

Returns:



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

#complex2(right, cmplx, **opts) ⇒ Vips::Image

Complex binary operations on two images.

Parameters:

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)

    Set of options

Returns:



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

#complexget(get, **opts) ⇒ Vips::Image

Get a component from a complex image.

Parameters:

Returns:



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

#composite(overlay, mode, **options) ⇒ Image

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

Parameters:

  • overlay (Image, Array<Image>)

    images to composite

  • mode (BlendMode, Array<BlendMode>)

    blend modes to use

  • opts (Hash)

    Set of options

Returns:

  • (Image)

    blended image



1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
# File 'lib/vips/image.rb', line 1289

def composite overlay, mode, **options
  unless overlay.is_a? Array
    overlay = [overlay]
  end
  unless mode.is_a? Array
    mode = [mode]
  end

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

  Vips::Image.composite([self] + overlay, mode, **options)
end

#composite2(overlay, mode, **opts) ⇒ Vips::Image

Blend a pair of images with a blend mode.

Parameters:

Options Hash (**opts):

  • :x (Integer)

    x position of overlay

  • :y (Integer)

    y position of overlay

  • :compositing_space (Vips::Interpretation)

    Composite images in this colour space

  • :premultiplied (Boolean)

    Images have premultiplied alpha

Returns:



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

#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



1382
1383
1384
# File 'lib/vips/image.rb', line 1382

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)

    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 2565

#conva(mask, **opts) ⇒ Vips::Image

Approximate integer convolution.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    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 2574

#convasep(mask, **opts) ⇒ Vips::Image

Approximate separable integer convolution.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :layers (Integer)

    Use this many layers in approximation

Returns:



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

#convf(mask, **opts) ⇒ Vips::Image

Float convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    Set of options

Returns:



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

#convi(mask, **opts) ⇒ Vips::Image

Int convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    Set of options

Returns:



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

#convsep(mask, **opts) ⇒ Vips::Image

Seperable convolution operation.

Parameters:

  • mask (Vips::Image)

    Input matrix image

  • opts (Hash)

    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 2606

#copy(**opts) ⇒ Vips::Image

Copy an image.

Parameters:

  • opts (Hash)

    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 265

#copy_memoryImage

Copy an image to a memory area.

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

Returns:

  • (Image)

    new memory image



966
967
968
969
# File 'lib/vips/image.rb', line 966

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

#cosImage

Return the cosine of an image in degrees.

Returns:

  • (Image)

    cosine of each pixel



1404
1405
1406
# File 'lib/vips/image.rb', line 1404

def cos
  math :cos
end

#coshImage

Return the hyperbolic cosine of an image in radians.

Returns:

  • (Image)

    cosine of each pixel



1446
1447
1448
# File 'lib/vips/image.rb', line 1446

def cosh
  math :cosh
end

#countlines(direction, **opts) ⇒ Float

Count lines in an image.

Parameters:

  • direction (Vips::Direction)

    Countlines left-right or up-down

  • opts (Hash)

    Set of options

Returns:

  • (Float)

    Number of lines



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

#crop(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)

    Set of options

Returns:



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

#cross_phase(other) ⇒ Image

Calculate the cross phase of two images.

Parameters:

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

    cross phase with this

Returns:

  • (Image)

    cross phase



1390
1391
1392
# File 'lib/vips/image.rb', line 1390

def cross_phase other
  complex2 other, :cross_phase
end

#csvsave(filename, **opts) ⇒ nil

Save image to csv.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :separator (String)

    Separator characters

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#csvsave_target(target, **opts) ⇒ nil

Save image to csv.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :separator (String)

    Separator characters

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#dE00(right, **opts) ⇒ Vips::Image

Calculate de00.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash)

    Set of options

Returns:



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

#dE76(right, **opts) ⇒ Vips::Image

Calculate de76.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash)

    Set of options

Returns:



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

#dECMC(right, **opts) ⇒ Vips::Image

Calculate decmc.

Parameters:

  • right (Vips::Image)

    Right-hand input image

  • opts (Hash)

    Set of options

Returns:



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

#deviate(**opts) ⇒ Float

Find image standard deviation.

Parameters:

  • opts (Hash)

    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



1540
1541
1542
# File 'lib/vips/image.rb', line 1540

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)

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

    Color for pixels

  • cx (Integer)

    Centre of draw_circle

  • cy (Integer)

    Centre of draw_circle

  • radius (Integer)

    Radius in pixels

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :fill (Boolean)

    Draw a solid object

Returns:



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

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

Flood-fill an area.

Parameters:

  • ink (Array<Double>)

    Color for pixels

  • x (Integer)

    DrawFlood start point

  • y (Integer)

    DrawFlood start point

  • opts (Hash)

    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 2766

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

    Set of options

Options Hash (**opts):

  • :mode (Vips::CombineMode)

    Combining mode

Returns:



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

#draw_line(ink, x1, y1, x2, y2, **opts) ⇒ Vips::Image

Draw a line on an image.

Parameters:

  • ink (Array<Double>)

    Color 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)

    Set of options

Returns:



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

#draw_mask(ink, mask, x, y, **opts) ⇒ Vips::Image

Draw a mask on an image.

Parameters:

  • ink (Array<Double>)

    Color for pixels

  • mask (Vips::Image)

    Mask of pixels to draw

  • x (Integer)

    Draw mask here

  • y (Integer)

    Draw mask here

  • opts (Hash)

    Set of options

Returns:



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

#draw_point(ink, left, top, **opts) ⇒ Image

Draw a point on an image.

See #draw_rect.

Returns:

  • (Image)

    modified image



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

def draw_point ink, left, top, **opts
  draw_rect ink, left, top, 1, 1, **opts
end

#draw_rect(ink, left, top, width, height, **opts) ⇒ Vips::Image

Paint a rectangle on an image.

Parameters:

  • ink (Array<Double>)

    Color for pixels

  • left (Integer)

    Rect to fill

  • top (Integer)

    Rect to fill

  • width (Integer)

    Rect to fill

  • height (Integer)

    Rect to fill

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :fill (Boolean)

    Draw a solid object

Returns:



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

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

    Set of options

Returns:



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

#dzsave(filename, **opts) ⇒ nil

Save image to deepzoom file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    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

  • :centre (Boolean)

    Center image in tile

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :angle (Vips::Angle)

    Rotate image during save

  • :container (Vips::ForeignDzContainer)

    Pyramid container type

  • :properties (Boolean)

    Write a properties file to the output directory

  • :compression (Integer)

    ZIP deflate compression level

  • :region_shrink (Vips::RegionShrink)

    Method to shrink regions

  • :skip_blanks (Integer)

    Skip tiles which are nearly equal to the background

  • :no_strip (Boolean)

    Don't strip tile metadata

  • :id (String)

    Resource ID

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#dzsave_buffer(**opts) ⇒ VipsBlob

Save image to dz buffer.

Parameters:

  • opts (Hash)

    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

  • :centre (Boolean)

    Center image in tile

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :angle (Vips::Angle)

    Rotate image during save

  • :container (Vips::ForeignDzContainer)

    Pyramid container type

  • :properties (Boolean)

    Write a properties file to the output directory

  • :compression (Integer)

    ZIP deflate compression level

  • :region_shrink (Vips::RegionShrink)

    Method to shrink regions

  • :skip_blanks (Integer)

    Skip tiles which are nearly equal to the background

  • :no_strip (Boolean)

    Don't strip tile metadata

  • :id (String)

    Resource ID

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

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

    Set of options

Options Hash (**opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels

Returns:



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

#erode(mask) ⇒ Image

Erode with a structuring element.

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

Parameters:

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

    structuring element

Returns:

  • (Image)

    eroded image



1528
1529
1530
# File 'lib/vips/image.rb', line 1528

def erode mask
  morph mask, :erode
end

#expImage

Return e ** pixel.

Returns:



1495
1496
1497
# File 'lib/vips/image.rb', line 1495

def exp
  math :exp
end

#exp10Image

Return 10 ** pixel.

Returns:

  • (Image)

    10 ** pixel



1502
1503
1504
# File 'lib/vips/image.rb', line 1502

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)

    Set of options

Returns:



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

#extract_band(band, **opts) ⇒ Vips::Image

Extract band from an image.

Parameters:

  • band (Integer)

    Band to extract

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :n (Integer)

    Number of bands to extract

Returns:



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

#falsecolour(**opts) ⇒ Vips::Image

False-color an image.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#fastcor(ref, **opts) ⇒ Vips::Image

Fast correlation.

Parameters:

  • ref (Vips::Image)

    Input reference image

  • opts (Hash)

    Set of options

Returns:



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

#filenameString

Get image filename, if any.

Returns:

  • (String)

    image filename



879
880
881
# File 'lib/vips/image.rb', line 879

def filename
  get "filename"
end

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

Fill image zeros with nearest non-zero pixel.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :distance (Vips::Image)

    Output Distance to nearest non-zero pixel

Returns:

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

    Value of nearest non-zero pixel, Hash of optional output items



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

#find_trim(**opts) ⇒ Array<Integer, Integer, Integer, Integer>

Search an image for non-edge areas.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :threshold (Float)

    Object threshold

  • :background (Array<Double>)

    Color for background pixels

Returns:

  • (Array<Integer, Integer, Integer, Integer>)

    Left edge of image, Top edge of extract area, Width of extract area, Height of extract area



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

#fitssave(filename, **opts) ⇒ nil

Save image to fits file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#flatten(**opts) ⇒ Vips::Image

Flatten alpha out of an image.

Parameters:

  • opts (Hash)

    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 483

#flip(direction, **opts) ⇒ Vips::Image

Flip an image.

Parameters:

  • direction (Vips::Direction)

    Direction to flip image

  • opts (Hash)

    Set of options

Returns:



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

#fliphorImage

Flip horizontally.

Returns:

  • (Image)

    image flipped horizontally



1509
1510
1511
# File 'lib/vips/image.rb', line 1509

def fliphor
  flip :horizontal
end

#flipverImage

Flip vertically.

Returns:

  • (Image)

    image flipped vertically



1516
1517
1518
# File 'lib/vips/image.rb', line 1516

def flipver
  flip :vertical
end

#float2rad(**opts) ⇒ Vips::Image

Transform float rgb to radiance coding.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#floorImage

Return the largest integral value not greater than the argument.

Returns:

  • (Image)

    floor of image



1213
1214
1215
# File 'lib/vips/image.rb', line 1213

def floor
  round :floor
end

#formatSymbol

Get image format.

Returns:

  • (Symbol)

    image format



858
859
860
# File 'lib/vips/image.rb', line 858

def format
  get "format"
end

#freqmult(mask, **opts) ⇒ Vips::Image

Frequency-domain filtering.

Parameters:

  • mask (Vips::Image)

    Input mask image

  • opts (Hash)

    Set of options

Returns:



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

#fwfft(**opts) ⇒ Vips::Image

Forward fft.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#gamma(**opts) ⇒ Vips::Image

Gamma an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :exponent (Float)

    Gamma factor

Returns:



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

#gaussblur(sigma, **opts) ⇒ Vips::Image

Gaussian blur.

Parameters:

  • sigma (Float)

    Sigma of Gaussian

  • opts (Hash)

    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 2645

#get(name) ⇒ Object

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

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

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

and profile will be an array containing the profile.

Parameters:

  • name (String)

    Metadata field to get

Returns:

Raises:



739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'lib/vips/image.rb', line 739

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

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

  result
end

#get_fields[String]

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

Returns:

  • ([String])

    array of field names



758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/vips/image.rb', line 758

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

  array = Vips.vips_image_get_fields self

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

  names
end

#get_typeof(name) ⇒ Integer

Get the GType of a metadata field. The result is 0 if no such field exists.

Parameters:

  • name (String)

    Metadata field to fetch

Returns:

  • (Integer)

    GType

See Also:



715
716
717
718
719
720
721
722
723
724
# File 'lib/vips/image.rb', line 715

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

  Vips.vips_image_get_typeof self, name
end

#get_value(name) ⇒ Object

compatibility: old name for get



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

def get_value name
  get name
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)

    Set of options

Returns:

  • (Array<Double>)

    Array of output values



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

#gifsave(filename, **opts) ⇒ nil

Save as gif.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#gifsave_buffer(**opts) ⇒ VipsBlob

Save as gif.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#gifsave_target(target, **opts) ⇒ nil

Save as gif.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#globalbalance(**opts) ⇒ Vips::Image

Global balance an image mosaic.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :gamma (Float)

    Image gamma

  • :int_output (Boolean)

    Integer output

Returns:



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

#gravity(direction, width, height, **opts) ⇒ Vips::Image

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

Parameters:

  • direction (Vips::CompassDirection)

    direction to place image within width/height

  • width (Integer)

    Image width in pixels

  • height (Integer)

    Image height in pixels

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels

Returns:



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

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

    Set of options

Returns:



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

#has_alpha?Boolean

Detect if image has an alpha channel

Returns:

  • (Boolean)

    true if image has an alpha channel.



940
941
942
# File 'lib/vips/image.rb', line 940

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

#heifsave(filename, **opts) ⇒ nil

Save image in heif format.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#heifsave_buffer(**opts) ⇒ VipsBlob

Save image in heif format.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#heifsave_target(target, **opts) ⇒ nil

Save image in heif format.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#heightInteger

Get image height, in pixels.

Returns:

  • (Integer)

    image height, in pixels



844
845
846
# File 'lib/vips/image.rb', line 844

def height
  Vips.vips_image_get_height self
end

#hist_cum(**opts) ⇒ Vips::Image

Form cumulative histogram.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#hist_entropy(**opts) ⇒ Float

Estimate image entropy.

Parameters:

  • opts (Hash)

    Set of options

Returns:

  • (Float)

    Output value



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

#hist_equal(**opts) ⇒ Vips::Image

Histogram equalisation.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :band (Integer)

    Equalise with this band

Returns:



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

#hist_find(**opts) ⇒ Vips::Image

Find image histogram.

Parameters:

  • opts (Hash)

    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)

    Set of options

Options Hash (**opts):

  • :combine (Vips::Combine)

    Combine bins like this

Returns:



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

#hist_find_ndim(**opts) ⇒ Vips::Image

Find n-dimensional image histogram.

Parameters:

  • opts (Hash)

    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)

    Set of options

Returns:

  • (Boolean)

    true if in is monotonic



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

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

    Set of options

Options Hash (**opts):

  • :max_slope (Integer)

    Maximum slope (CLAHE)

Returns:



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

#hist_match(ref, **opts) ⇒ Vips::Image

Match two histograms.

Parameters:

  • ref (Vips::Image)

    Reference histogram

  • opts (Hash)

    Set of options

Returns:



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

#hist_norm(**opts) ⇒ Vips::Image

Normalise histogram.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#hist_plot(**opts) ⇒ Vips::Image

Plot histogram.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#hough_circle(**opts) ⇒ Vips::Image

Find hough circle transform.

Parameters:

  • opts (Hash)

    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 222

#hough_line(**opts) ⇒ Vips::Image

Find hough line transform.

Parameters:

  • opts (Hash)

    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 215

#HSV2sRGB(**opts) ⇒ Vips::Image

Transform hsv to srgb.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#icc_export(**opts) ⇒ Vips::Image

Output to device with icc profile.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :black_point_compensation (Boolean)

    Enable black point compensation

  • :output_profile (String)

    Filename to load output profile from

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

#icc_import(**opts) ⇒ Vips::Image

Import from device with icc profile.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :black_point_compensation (Boolean)

    Enable black point compensation

  • :embedded (Boolean)

    Use embedded input profile, if available

  • :input_profile (String)

    Filename to load input profile from

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

  • :black_point_compensation (Boolean)

    Enable black point compensation

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

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

    set of options

Options Hash (**opts):

  • :blend (Boolean) — default: false

    Blend smoothly between th and el

Returns:

  • (Image)

    merged image



1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
# File 'lib/vips/image.rb', line 1574

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

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

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

#imagImage

Return the imaginary part of a complex image.

Returns:

  • (Image)

    imaginary part of complex image



1344
1345
1346
# File 'lib/vips/image.rb', line 1344

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)

    Set of options

Options Hash (**opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :background (Array<Double>)

    Color for new pixels

Returns:



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

#inspectObject



172
173
174
# File 'lib/vips/image.rb', line 172

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

#interpretationSymbol

Get image interpretation.

Returns:

  • (Symbol)

    image interpretation



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

def interpretation
  get "interpretation"
end

#invert(**opts) ⇒ Vips::Image

Invert an image.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#invertlut(**opts) ⇒ Vips::Image

Build an inverted look-up table.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :size (Integer)

    LUT size to generate

Returns:



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

#invfft(**opts) ⇒ Vips::Image

Inverse fft.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :real (Boolean)

    Output only the real part of the transform

Returns:



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

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

    Set of options

Options Hash (**opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :align (Vips::Align)

    Align on the low, centre or high coordinate edge

Returns:



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

#jp2ksave(filename, **opts) ⇒ nil

Save image in jpeg2000 format.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Q factor

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jp2ksave_buffer(**opts) ⇒ VipsBlob

Save image in jpeg2000 format.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Q factor

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#jp2ksave_target(target, **opts) ⇒ nil

Save image in jpeg2000 format.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Q factor

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jpegsave(filename, **opts) ⇒ nil

Save image to jpeg file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    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

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :restart_interval (Integer)

    Add restart markers every specified number of mcu

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jpegsave_buffer(**opts) ⇒ VipsBlob

Save image to jpeg buffer.

Parameters:

  • opts (Hash)

    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

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :restart_interval (Integer)

    Add restart markers every specified number of mcu

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#jpegsave_mime(**opts) ⇒ nil

Save image to jpeg mime.

Parameters:

  • opts (Hash)

    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

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :restart_interval (Integer)

    Add restart markers every specified number of mcu

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jpegsave_target(target, **opts) ⇒ nil

Save image to jpeg target.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    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

  • :trellis_quant (Boolean)

    Apply trellis quantisation to each 8x8 block

  • :overshoot_deringing (Boolean)

    Apply overshooting to samples with extreme values

  • :optimize_scans (Boolean)

    Split spectrum of DCT coefficients into separate scans

  • :quant_table (Integer)

    Use predefined quantization table with given index

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :restart_interval (Integer)

    Add restart markers every specified number of mcu

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jxlsave(filename, **opts) ⇒ nil

Save image in jpeg-xl format.

Parameters:

  • filename (String)

    Filename to load from

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tier (Integer)

    Decode speed tier

  • :distance (Float)

    Target butteraugli distance

  • :effort (Integer)

    Encoding effort

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Quality factor

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#jxlsave_buffer(**opts) ⇒ VipsBlob

Save image in jpeg-xl format.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tier (Integer)

    Decode speed tier

  • :distance (Float)

    Target butteraugli distance

  • :effort (Integer)

    Encoding effort

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Quality factor

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#jxlsave_target(target, **opts) ⇒ nil

Save image in jpeg-xl format.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tier (Integer)

    Decode speed tier

  • :distance (Float)

    Target butteraugli distance

  • :effort (Integer)

    Encoding effort

  • :lossless (Boolean)

    Enable lossless compression

  • :Q (Integer)

    Quality factor

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#Lab2LabQ(**opts) ⇒ Vips::Image

Transform float lab to labq coding.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#Lab2LabS(**opts) ⇒ Vips::Image

Transform float lab to signed short.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#Lab2LCh(**opts) ⇒ Vips::Image

Transform lab to lch.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#Lab2XYZ(**opts) ⇒ Vips::Image

Transform cielab to xyz.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :temp (Array<Double>)

    Color temperature

Returns:



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

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

Label regions in an image.

Parameters:

  • opts (Hash)

    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 2714

#LabQ2Lab(**opts) ⇒ Vips::Image

Unpack a labq image to float lab.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LabQ2LabS(**opts) ⇒ Vips::Image

Unpack a labq image to short lab.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LabQ2sRGB(**opts) ⇒ Vips::Image

Convert a labq image to srgb.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LabS2Lab(**opts) ⇒ Vips::Image

Transform signed short lab to float.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LabS2LabQ(**opts) ⇒ Vips::Image

Transform short lab to labq coding.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LCh2CMC(**opts) ⇒ Vips::Image

Transform lch to cmc.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#LCh2Lab(**opts) ⇒ Vips::Image

Transform lch to lab.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#linear(a, b, **opts) ⇒ Vips::Image

Calculate (a * in + b).

Parameters:

  • a (Array<Double>)

    Multiply by this

  • b (Array<Double>)

    Add this

  • opts (Hash)

    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)

    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 291

#logImage

Return the natural log of an image.

Returns:

  • (Image)

    natural log of each pixel



1481
1482
1483
# File 'lib/vips/image.rb', line 1481

def log
  math :log
end

#log10Image

Return the log base 10 of an image.

Returns:

  • (Image)

    base 10 log of each pixel



1488
1489
1490
# File 'lib/vips/image.rb', line 1488

def log10
  math :log10
end

#magicksave(filename, **opts) ⇒ nil

Save file with imagemagick.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :format (String)

    Format to save in

  • :quality (Integer)

    Quality to use

  • :optimize_gif_frames (Boolean)

    Apply GIF frames optimization

  • :optimize_gif_transparency (Boolean)

    Apply GIF transparency optimization

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#magicksave_buffer(**opts) ⇒ VipsBlob

Save image to magick buffer.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :format (String)

    Format to save in

  • :quality (Integer)

    Quality to use

  • :optimize_gif_frames (Boolean)

    Apply GIF frames optimization

  • :optimize_gif_transparency (Boolean)

    Apply GIF transparency optimization

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#mapim(index, **opts) ⇒ Vips::Image

Resample with a map image.

Parameters:

  • index (Vips::Image)

    Index pixels with this

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#maplut(lut, **opts) ⇒ Vips::Image

Map an image though a lut.

Parameters:

  • lut (Vips::Image)

    Look-up table image

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :band (Integer)

    apply one-band lut to this band of in

Returns:



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

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

    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 2855

#math(math, **opts) ⇒ Vips::Image

Apply a math operation to an image.

Parameters:

Returns:



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

#math2(right, math2, **opts) ⇒ Vips::Image

Binary math operations.

Parameters:

Returns:



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

#math2_const(math2, c, **opts) ⇒ Vips::Image

Binary math operations with a constant.

Parameters:

  • math2 (Vips::OperationMath2)

    math to perform

  • c (Array<Double>)

    Array of constants

  • opts (Hash)

    Set of options

Returns:



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

#matrixinvert(**opts) ⇒ Vips::Image

Invert an matrix.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#matrixprint(**opts) ⇒ nil

Print matrix.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#matrixsave(filename, **opts) ⇒ nil

Save image to matrix.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#matrixsave_target(target, **opts) ⇒ nil

Save image to matrix.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

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

Find image maximum.

Parameters:

  • opts (Hash)

    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



1308
1309
1310
1311
1312
1313
# File 'lib/vips/image.rb', line 1308

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

#measure(h, v, **opts) ⇒ Vips::Image

Measure a set of patches on a color chart.

Parameters:

  • h (Integer)

    Number of patches across chart

  • v (Integer)

    Number of patches down chart

  • opts (Hash)

    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 240

#median(size = 3) ⇒ Image

a median filter

Parameters:

  • size (Integer) (defaults to: 3)

    size of filter window

Returns:

  • (Image)

    result of median filter



1330
1331
1332
# File 'lib/vips/image.rb', line 1330

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

#merge(sec, direction, dx, dy, **opts) ⇒ Vips::Image

Merge two images.

Parameters:

  • sec (Vips::Image)

    Secondary image

  • direction (Vips::Direction)

    Horizontal or vertical merge

  • dx (Integer)

    Horizontal displacement from sec to ref

  • dy (Integer)

    Vertical displacement from sec to ref

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :mblend (Integer)

    Maximum blend size

Returns:



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

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

Find image minimum.

Parameters:

  • opts (Hash)

    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



1319
1320
1321
1322
1323
1324
# File 'lib/vips/image.rb', line 1319

def minpos
  v, opts = min x: true, y: true
  x = opts["x"]
  y = opts["y"]
  [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)

    Set of options

Returns:



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

#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 vertical 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)

    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

  • :dy1 (Float)

    Output Detected first-order displacement

  • :dx1 (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 2808

#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 vertical 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)

    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 2829

#msb(**opts) ⇒ Vips::Image

Pick most-significant byte from an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :band (Integer)

    Band to msb

Returns:



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

#multiply(right, **opts) ⇒ Vips::Image

Multiply two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash)

    Set of options

Returns:



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

#mutate {|mutable| ... } ⇒ Object

Mutate an image with a block. Inside the block, you can call methods which modify the image, such as setting or removing metadata, or modifying pixels.

For example:

image = image.mutate do |x|
  (0 ... 1).step(0.01) do |i|
    x.draw_line! 255, x.width * i, 0, 0, x.height * (1 - i)
  end
end

See MutableImage.

Yields:

  • (mutable)


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

def mutate
  mutable = Vips::MutableImage.new self
  yield mutable
  mutable.image
end

#new_from_image(value) ⇒ Image

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

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

Parameters:

  • value (Real, Array<Real>)

    value to put in each pixel

Returns:

  • (Image)

    constant image



526
527
528
529
530
531
# File 'lib/vips/image.rb', line 526

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

#niftisave(filename, **opts) ⇒ nil

Save image to nifti file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#offsetFloat

Get offset metadata.

Returns:

  • (Float)

    image offset



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

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

  get "offset"
end

#parent_get_typeofObject



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

alias_method :parent_get_typeof, :get_typeof

#percent(percent, **opts) ⇒ Integer

Find threshold for percent of pixels.

Parameters:

  • percent (Float)

    Percent of pixels

  • opts (Hash)

    Set of options

Returns:

  • (Integer)

    Threshold above which lie percent of pixels



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

#phasecor(in2, **opts) ⇒ Vips::Image

Calculate phase correlation.

Parameters:

  • in2 (Vips::Image)

    Second input image

  • opts (Hash)

    Set of options

Returns:



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

#pngsave(filename, **opts) ⇒ nil

Save image to png file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    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)

  • :palette (Boolean)

    Quantise to 8bpp palette

  • :Q (Integer)

    Quantisation quality

  • :dither (Float)

    Amount of dithering

  • :bitdepth (Integer)

    Write as a 1, 2, 4 or 8 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#pngsave_buffer(**opts) ⇒ VipsBlob

Save image to png buffer.

Parameters:

  • opts (Hash)

    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)

  • :palette (Boolean)

    Quantise to 8bpp palette

  • :Q (Integer)

    Quantisation quality

  • :dither (Float)

    Amount of dithering

  • :bitdepth (Integer)

    Write as a 1, 2, 4 or 8 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#pngsave_target(target, **opts) ⇒ nil

Save image to target as png.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    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)

  • :palette (Boolean)

    Quantise to 8bpp palette

  • :Q (Integer)

    Quantisation quality

  • :dither (Float)

    Amount of dithering

  • :bitdepth (Integer)

    Write as a 1, 2, 4 or 8 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

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



1357
1358
1359
# File 'lib/vips/image.rb', line 1357

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)

    Set of options

Options Hash (**opts):

  • :format (Vips::ForeignPpmFormat)

    Format to save in

  • :ascii (Boolean)

    save as ascii

  • :bitdepth (Integer)

    set to 1 to write as a 1 bit image

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#ppmsave_target(target, **opts) ⇒ nil

Save to ppm.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :format (Vips::ForeignPpmFormat)

    Format to save in

  • :ascii (Boolean)

    save as ascii

  • :bitdepth (Integer)

    set to 1 to write as a 1 bit image

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#premultiply(**opts) ⇒ Vips::Image

Premultiply image alpha.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :max_alpha (Float)

    Maximum value of alpha channel

Returns:



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

#profile(**opts) ⇒ Array<Vips::Image, Vips::Image>

Find image profiles.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#project(**opts) ⇒ Array<Vips::Image, Vips::Image>

Find image projections.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#quadratic(coeff, **opts) ⇒ Vips::Image

Resample an image with a quadratic transform.

Parameters:

  • coeff (Vips::Image)

    Coefficient matrix

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#rad2float(**opts) ⇒ Vips::Image

Unpack radiance coding to float rgb.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#radsave(filename, **opts) ⇒ nil

Save image to radiance file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#radsave_buffer(**opts) ⇒ VipsBlob

Save image to radiance buffer.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#radsave_target(target, **opts) ⇒ nil

Save image to radiance target.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

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

    Set of options

Returns:



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

#rawsave(filename, **opts) ⇒ nil

Save image to raw file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#rawsave_fd(fd, **opts) ⇒ nil

Write raw image to file descriptor.

Parameters:

  • fd (Integer)

    File descriptor to write to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#realImage

Return the real part of a complex image.

Returns:

  • (Image)

    real part of complex image



1337
1338
1339
# File 'lib/vips/image.rb', line 1337

def real
  complexget :real
end

#recomb(m, **opts) ⇒ Vips::Image

Linear recombination with matrix.

Parameters:

  • m (Vips::Image)

    matrix of coefficients

  • opts (Hash)

    Set of options

Returns:



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

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



1370
1371
1372
# File 'lib/vips/image.rb', line 1370

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)

    Set of options

Options Hash (**opts):

Returns:



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

#reduceh(hshrink, **opts) ⇒ Vips::Image

Shrink an image horizontally.

Parameters:

  • hshrink (Float)

    Horizontal shrink factor

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#reducev(vshrink, **opts) ⇒ Vips::Image

Shrink an image vertically.

Parameters:

  • vshrink (Float)

    Vertical shrink factor

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#relational(right, relational, **opts) ⇒ Vips::Image

Relational operation on two images.

Parameters:

Returns:



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

#relational_const(relational, c, **opts) ⇒ Vips::Image

Relational operations against a constant.

Parameters:

  • relational (Vips::OperationRelational)

    relational to perform

  • c (Array<Double>)

    Array of constants

  • opts (Hash)

    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)

    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)

    Set of options

Returns:



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

#remove(name) ⇒ Object

This method is deprecated.

Please use MutableImage#remove! instead.



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

def remove name
  Vips.vips_image_remove self, name
end

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

    Set of options

Returns:



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

#resize(scale, **opts) ⇒ Vips::Image

Resize an image.

Parameters:

  • scale (Float)

    Scale image by this factor

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :vscale (Float)

    Vertical scale image by this factor

Returns:



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

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

Returns:

  • (Boolean)


176
177
178
179
180
181
182
183
184
185
# File 'lib/vips/image.rb', line 176

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

  super
end

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

Returns:

  • (Boolean)


187
188
189
190
191
192
# File 'lib/vips/image.rb', line 187

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

  super
end

#rintImage

Return the nearest integral value.

Returns:

  • (Image)

    rint of image



1227
1228
1229
# File 'lib/vips/image.rb', line 1227

def rint
  round :rint
end

#rot(angle, **opts) ⇒ Vips::Image

Rotate an image.

Parameters:

  • angle (Vips::Angle)

    Angle to rotate image

  • opts (Hash)

    Set of options

Returns:



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

#rot180Image

Rotate by 180 degrees clockwise.

Returns:

  • (Image)

    rotated image



1554
1555
1556
# File 'lib/vips/image.rb', line 1554

def rot180
  rot :d180
end

#rot270Image

Rotate by 270 degrees clockwise.

Returns:

  • (Image)

    rotated image



1561
1562
1563
# File 'lib/vips/image.rb', line 1561

def rot270
  rot :d270
end

#rot45(**opts) ⇒ Vips::Image

Rotate an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#rot90Image

Rotate by 90 degrees clockwise.

Returns:

  • (Image)

    rotated image



1547
1548
1549
# File 'lib/vips/image.rb', line 1547

def rot90
  rot :d90
end

#rotate(angle, **opts) ⇒ Vips::Image

Rotate an image by a number of degrees.

Parameters:

  • angle (Float)

    Rotate anticlockwise by this many degrees

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :background (Array<Double>)

    Background value

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

#round(round, **opts) ⇒ Vips::Image

Perform a round function on an image.

Parameters:

Returns:



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

#scaleFloat

Get scale metadata.

Returns:

  • (Float)

    image scale



914
915
916
917
918
# File 'lib/vips/image.rb', line 914

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

  get "scale"
end

#scaleimage(**options) ⇒ Vips::Image

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

Parameters:

  • opts (Hash)

    Set of options

Returns:



1592
1593
1594
# File 'lib/vips/image.rb', line 1592

def scaleimage **options
  Vips::Image.scale self, **options
end

#scRGB2BW(**opts) ⇒ Vips::Image

Convert scrgb to bw.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

#scRGB2sRGB(**opts) ⇒ Vips::Image

Convert an scrgb image to srgb.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :depth (Integer)

    Output device space depth in bits

Returns:



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

#scRGB2XYZ(**opts) ⇒ Vips::Image

Transform scrgb to xyz.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#sequential(**opts) ⇒ Vips::Image

Check sequential access.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :tile_height (Integer)

    Tile height in pixels

Returns:



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

#set(name, value) ⇒ Object

This method is deprecated.

Please use MutableImage#set! instead.



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

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

#set_kill(kill) ⇒ Object

Kill computation of this time.

Set true to stop computation of this image. You can call this from a progress handler, for example.

Parameters:

  • kill (Boolean)

    stop computation

See Also:



705
706
707
# File 'lib/vips/image.rb', line 705

def set_kill kill
  Vips.vips_image_set_kill self, kill
end

#set_progress(state) ⇒ Object

Turn progress signalling on and off.

If this is on, the most-downstream image from this image will issue progress signals.

Parameters:

  • state (Boolean)

    progress signalling state

See Also:



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

def set_progress state
  Vips.vips_image_set_progress self, state
end

#set_type(gtype, name, value) ⇒ Object

This method is deprecated.

Please use MutableImage#set_type! instead.



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

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

#set_value(name, value) ⇒ Object

This method is deprecated.

Please use MutableImage#set! instead.



830
831
832
# File 'lib/vips/image.rb', line 830

def set_value name, value
  set name, value
end

#sharpen(**opts) ⇒ Vips::Image

Unsharp masking for print.

Parameters:

  • opts (Hash)

    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 2634

#shrink(hshrink, vshrink, **opts) ⇒ Vips::Image

Shrink an image.

Parameters:

  • hshrink (Float)

    Horizontal shrink factor

  • vshrink (Float)

    Vertical shrink factor

  • opts (Hash)

    Set of options

Returns:



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

#shrinkh(hshrink, **opts) ⇒ Vips::Image

Shrink an image horizontally.

Parameters:

  • hshrink (Integer)

    Horizontal shrink factor

  • opts (Hash)

    Set of options

Returns:



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

#shrinkv(vshrink, **opts) ⇒ Vips::Image

Shrink an image vertically.

Parameters:

  • vshrink (Integer)

    Vertical shrink factor

  • opts (Hash)

    Set of options

Returns:



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

#sign(**opts) ⇒ Vips::Image

Unit vector of pixel.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#similarity(**opts) ⇒ Vips::Image

Similarity transform of an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :scale (Float)

    Scale by this factor

  • :angle (Float)

    Rotate anticlockwise by this many degrees

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :background (Array<Double>)

    Background value

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

#sinImage

Return the sine of an image in degrees.

Returns:

  • (Image)

    sine of each pixel



1397
1398
1399
# File 'lib/vips/image.rb', line 1397

def sin
  math :sin
end

#sinhImage

Return the hyperbolic sine of an image in radians.

Returns:

  • (Image)

    sine of each pixel



1439
1440
1441
# File 'lib/vips/image.rb', line 1439

def sinh
  math :sinh
end

#sizeInteger

Get the image size.

Returns:

  • (Integer, Integer)

    image width and height



932
933
934
# File 'lib/vips/image.rb', line 932

def size
  [width, height]
end

#smartcrop(width, height, **opts) ⇒ Vips::Image

Extract an area from an image.

Parameters:

  • width (Integer)

    Width of extract area

  • height (Integer)

    Height of extract area

  • opts (Hash)

    Set of options

Options Hash (**opts):

Returns:



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

#sobel(**opts) ⇒ Vips::Image

Sobel edge detector.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#spcor(ref, **opts) ⇒ Vips::Image

Spatial correlation.

Parameters:

  • ref (Vips::Image)

    Input reference image

  • opts (Hash)

    Set of options

Returns:



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

#spectrum(**opts) ⇒ Vips::Image

Make displayable power spectrum.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#sRGB2HSV(**opts) ⇒ Vips::Image

Transform srgb to hsv.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#sRGB2scRGB(**opts) ⇒ Vips::Image

Convert an srgb image to scrgb.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#stats(**opts) ⇒ Vips::Image

Find many image stats.

Parameters:

  • opts (Hash)

    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)

    Set of options

Options Hash (**opts):

  • :s0 (Float)

    New deviation

  • :b (Float)

    Weight of new deviation

  • :m0 (Float)

    New mean

  • :a (Float)

    Weight of new mean

Returns:



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

#subsample(xfac, yfac, **opts) ⇒ Vips::Image

Subsample an image.

Parameters:

  • xfac (Integer)

    Horizontal subsample factor

  • yfac (Integer)

    Vertical subsample factor

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :point (Boolean)

    Point sample

Returns:



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

#subtract(right, **opts) ⇒ Vips::Image

Subtract two images.

Parameters:

  • right (Vips::Image)

    Right-hand image argument

  • opts (Hash)

    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



1411
1412
1413
# File 'lib/vips/image.rb', line 1411

def tan
  math :tan
end

#tanhImage

Return the hyperbolic tangent of an image in radians.

Returns:

  • (Image)

    tangent of each pixel



1453
1454
1455
# File 'lib/vips/image.rb', line 1453

def tanh
  math :tanh
end

#thumbnail_image(width, **opts) ⇒ Vips::Image

Generate thumbnail from image.

Parameters:

  • width (Integer)

    Size to this width

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

  • :no_rotate (Boolean)

    Don't use orientation tags to rotate image upright

  • :crop (Vips::Interesting)

    Reduce to fill target rectangle, then crop

  • :linear (Boolean)

    Reduce in linear light

  • :import_profile (String)

    Fallback import profile

  • :export_profile (String)

    Fallback export profile

  • :intent (Vips::Intent)

    Rendering intent

Returns:



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

#tiffsave(filename, **opts) ⇒ nil

Save image to tiff file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    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

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :bitdepth (Integer)

    Write as a 1, 2, 4 or 8 bit image

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

  • :region_shrink (Vips::RegionShrink)

    Method to shrink regions

  • :level (Integer)

    ZSTD compression level

  • :lossless (Boolean)

    Enable WEBP lossless mode

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :subifd (Boolean)

    Save pyr layers as sub-IFDs

  • :premultiply (Boolean)

    Save with premultiplied alpha

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#tiffsave_buffer(**opts) ⇒ VipsBlob

Save image to tiff buffer.

Parameters:

  • opts (Hash)

    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

  • :miniswhite (Boolean)

    Use 0 for white in 1-bit images

  • :bitdepth (Integer)

    Write as a 1, 2, 4 or 8 bit image

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

  • :region_shrink (Vips::RegionShrink)

    Method to shrink regions

  • :level (Integer)

    ZSTD compression level

  • :lossless (Boolean)

    Enable WEBP lossless mode

  • :depth (Vips::ForeignDzDepth)

    Pyramid depth

  • :subifd (Boolean)

    Save pyr layers as sub-IFDs

  • :premultiply (Boolean)

    Save with premultiplied alpha

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#tilecache(**opts) ⇒ Vips::Image

Cache an image as a set of tiles.

Parameters:

  • opts (Hash)

    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 280

#to_aArray

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

Returns:

  • (Array)

    Array of Arrays of Arrays of Numerics



1206
1207
1208
# File 'lib/vips/image.rb', line 1206

def to_a
  to_enum.to_a
end

#to_enumEnumerator

Convert to an Enumerator. Similar to #to_a but lazier.

Returns:

  • (Enumerator)

    Enumerator of Enumerators of Arrays of Numerics



1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
# File 'lib/vips/image.rb', line 1177

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

  # we render the image to a big string, then unpack into
  # one-dimensional array as a Ruby array of the correct type
  array = write_to_memory.unpack template

  # gather bands of a pixel together
  pixel_array = array.each_slice bands

  # gather pixels of a row together
  pixel_array.each_slice width
end

#transpose3d(**opts) ⇒ Vips::Image

Transpose3d an image.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :page_height (Integer)

    Height of each input page

Returns:



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

#unpremultiply(**opts) ⇒ Vips::Image

Unpremultiply image alpha.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :max_alpha (Float)

    Maximum value of alpha channel

  • :alpha_band (Integer)

    Unpremultiply with this alpha

Returns:



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

#vipssave(filename, **opts) ⇒ nil

Save image to file in vips format.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#vipssave_target(target, **opts) ⇒ nil

Save image to target in vips format.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#webpsave(filename, **opts) ⇒ nil

Save image to webp file.

Parameters:

  • filename (String)

    Filename to save to

  • opts (Hash)

    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

  • :min_size (Boolean)

    Optimise for minium size

  • :kmin (Integer)

    Minimum number of frames between key frames

  • :kmax (Integer)

    Maximum number of frames between key frames

  • :effort (Integer)

    Level of CPU effort to reduce file size

  • :profile (String)

    ICC profile to embed

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#webpsave_buffer(**opts) ⇒ VipsBlob

Save image to webp buffer.

Parameters:

  • opts (Hash)

    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

  • :min_size (Boolean)

    Optimise for minium size

  • :kmin (Integer)

    Minimum number of frames between key frames

  • :kmax (Integer)

    Maximum number of frames between key frames

  • :effort (Integer)

    Level of CPU effort to reduce file size

  • :profile (String)

    ICC profile to embed

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (VipsBlob)

    Buffer to save to



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

#webpsave_target(target, **opts) ⇒ nil

Save image to webp target.

Parameters:

  • target (Vips::Target)

    Target to save to

  • opts (Hash)

    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

  • :min_size (Boolean)

    Optimise for minium size

  • :kmin (Integer)

    Minimum number of frames between key frames

  • :kmax (Integer)

    Maximum number of frames between key frames

  • :effort (Integer)

    Level of CPU effort to reduce file size

  • :profile (String)

    ICC profile to embed

  • :strip (Boolean)

    Strip all metadata from image

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

Returns:

  • (nil)


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

#widthInteger

Get image width, in pixels.

Returns:

  • (Integer)

    image width, in pixels



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

def width
  Vips.vips_image_get_width self
end

#wrap(**opts) ⇒ Vips::Image

Wrap image origin.

Parameters:

  • opts (Hash)

    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 517

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

    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

Raises:



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/vips/image.rb', line 600

def write_to_buffer format_string, **opts
  raise Vips::Error, "filename is nil" if format_string.nil?
  filename = Vips.p2str(Vips.vips_filename_get_filename(format_string))
  option_string = Vips.p2str(Vips.vips_filename_get_options(format_string))

  # try to save with the new target API first, only fall back to the old
  # buffer API if there's no target save for this filetype
  saver = nil
  if Vips.at_least_libvips?(8, 9)
    Vips.vips_error_freeze
    saver = Vips.vips_foreign_find_save_target filename
    Vips.vips_error_thaw
  end

  if !saver.nil?
    target = Vips::Target.new_to_memory
    Vips::Operation.call saver, [self, target], opts, option_string
    buffer = target.get("blob")
  else
    saver = Vips.vips_foreign_find_save_buffer filename
    raise Vips::Error if saver.nil?

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

  GC.start(full_mark: false)

  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)

    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

Raises:



562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/vips/image.rb', line 562

def write_to_file name, **opts
  raise Vips::Error, "filename is nil" if name.nil?

  filename = Vips.p2str(Vips.vips_filename_get_filename(name))
  option_string = Vips.p2str(Vips.vips_filename_get_options(name))
  saver = Vips.vips_foreign_find_save filename
  raise Vips::Error if saver.nil?

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

  GC.start(full_mark: false)
end

#write_to_memoryString

Write this image to a large memory buffer.

Returns:

  • (String)

    the pixels as a huge binary string

Raises:



672
673
674
675
676
677
678
679
680
681
682
683
684
685
# File 'lib/vips/image.rb', line 672

def write_to_memory
  len = Vips::SizeStruct.new
  ptr = Vips.vips_image_write_to_memory self, len
  raise Vips::Error if ptr.nil?

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

  data = ptr.get_bytes 0, len[:value]

  GC.start(full_mark: false)

  return data
end

#write_to_target(target, format_string, **opts) ⇒ Object

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

target = Vips::Target.new_to_file "k2.jpg"
image.write_to_target target, ".jpg[Q=90]"

or equivalently:

image.write_to_target target, ".jpg", Q: 90

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

$ vips jpegsave_target

to see all the available options for JPEG save.

Parameters:

  • target (Vips::Target)

    the target to write to

  • format_string (String)

    save format plus string options

  • opts (Hash)

    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

Raises:



657
658
659
660
661
662
663
664
665
666
667
# File 'lib/vips/image.rb', line 657

def write_to_target target, format_string, **opts
  raise Vips::Error, "filename is nil" if format_string.nil?
  filename = Vips.p2str(Vips.vips_filename_get_filename(format_string))
  option_string = Vips.p2str(Vips.vips_filename_get_options(format_string))
  saver = Vips.vips_foreign_find_save_target filename
  raise Vips::Error if saver.nil?

  Vips::Operation.call saver, [self, target], opts, option_string

  GC.start(full_mark: false)
end

#xoffsetInteger

Get image xoffset.

Returns:

  • (Integer)

    image xoffset



886
887
888
# File 'lib/vips/image.rb', line 886

def xoffset
  get "xoffset"
end

#xresFloat

Get image x resolution.

Returns:

  • (Float)

    image x resolution



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

def xres
  get "xres"
end

#XYZ2CMYK(**opts) ⇒ Vips::Image

Transform xyz to cmyk.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#XYZ2Lab(**opts) ⇒ Vips::Image

Transform xyz to lab.

Parameters:

  • opts (Hash)

    Set of options

Options Hash (**opts):

  • :temp (Array<Double>)

    Colour temperature

Returns:



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

#XYZ2scRGB(**opts) ⇒ Vips::Image

Transform xyz to scrgb.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#XYZ2Yxy(**opts) ⇒ Vips::Image

Transform xyz to yxy.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#yoffsetInteger

Get image yoffset.

Returns:

  • (Integer)

    image yoffset



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

def yoffset
  get "yoffset"
end

#yresFloat

Get image y resolution.

Returns:

  • (Float)

    image y resolution



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

def yres
  get "yres"
end

#Yxy2XYZ(**opts) ⇒ Vips::Image

Transform yxy to xyz.

Parameters:

  • opts (Hash)

    Set of options

Returns:



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

#zoom(xfac, yfac, **opts) ⇒ Vips::Image

Zoom an image.

Parameters:

  • xfac (Integer)

    Horizontal zoom factor

  • yfac (Integer)

    Vertical zoom factor

  • opts (Hash)

    Set of options

Returns:



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

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



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

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

#~Image

Equivalent to image ^ -1

Returns:

  • (Image)

    image with bits flipped



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

def ~
  self ^ -1
end