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.



232
233
234
# File 'lib/vips/image.rb', line 232

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

Class Method Details

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

Load an analyze6 image.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Join an array of images.

Options Hash (**opts):

  • :across (Integer)

    Number of images across grid

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :halign (Vips::Align)

    Align on the left, centre or right

  • :valign (Vips::Align)

    Align on the top, centre or bottom

  • :hspacing (Integer)

    Horizontal spacing between images

  • :vspacing (Integer)

    Vertical spacing between images



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


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

Band-wise rank of a set of images.

Options Hash (**opts):

  • :index (Integer)

    Select this band element from sorted list



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


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

Make a black image.

Options Hash (**opts):

  • :bands (Integer)

    Number of bands in image



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


.complex?(format) ⇒ Boolean



120
121
122
123
# File 'lib/vips/image.rb', line 120

def self.complex? format
  format_number = GObject::GValue.enum_from_nick BAND_FORMAT_TYPE, format
  Vips.vips_band_format_iscomplex(format_number) != 0
end

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

Load csv.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load csv.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load raw camera files.

Options Hash (**opts):

  • :bitdepth (Integer)

    Number of bits per pixel

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load raw camera files.

Options Hash (**opts):

  • :bitdepth (Integer)

    Number of bits per pixel

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load raw camera files.

Options Hash (**opts):

  • :bitdepth (Integer)

    Number of bits per pixel

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Make an image showing the eye's spatial response.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :factor (Float)

    Maximum spatial frequency



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


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

Load a fits image.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load fits from a source.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


.float?(format) ⇒ Boolean



125
126
127
128
# File 'lib/vips/image.rb', line 125

def self.float? format
  format_number = GObject::GValue.enum_from_nick BAND_FORMAT_TYPE, format
  Vips.vips_band_format_isfloat(format_number) != 0
end

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

Make a fractal surface.



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


.gaussmat(sigma, min_ampl, **opts) ⇒ Vips::Image

Make a gaussian image.

Options Hash (**opts):

  • :separable (Boolean)

    Generate separable Gaussian

  • :precision (Vips::Precision)

    Generate with this precision



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


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

Make a gaussnoise image.

Options Hash (**opts):

  • :sigma (Float)

    Standard deviation of pixels in generated image

  • :mean (Float)

    Mean of pixels in generated image

  • :seed (Integer)

    Random number seed



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


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

Load gif with libnsgif.

Options Hash (**opts):

  • :n (Integer)

    Number of pages to load, -1 for all

  • :page (Integer)

    First page to 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load gif with libnsgif.

Options Hash (**opts):

  • :n (Integer)

    Number of pages to load, -1 for all

  • :page (Integer)

    First page to 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load gif from source.

Options Hash (**opts):

  • :n (Integer)

    Number of pages to load, -1 for all

  • :page (Integer)

    First page to 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Make a grey ramp image.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image



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


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

Load a heif image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :thumbnail (Boolean)

    Fetch thumbnail image

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load a heif image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :thumbnail (Boolean)

    Fetch thumbnail image

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load a heif image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :thumbnail (Boolean)

    Fetch thumbnail image

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Make a 1d image where pixel values are indexes.

Options Hash (**opts):

  • :bands (Integer)

    Number of bands in LUT

  • :ushort (Boolean)

    Create a 16-bit LUT

  • :size (Integer)

    Size of 16-bit LUT



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


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

Load jpeg2000 image.

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :oneshot (Boolean)

    Load images a frame at a time

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg2000 image.

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :oneshot (Boolean)

    Load images a frame at a time

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg2000 image.

Options Hash (**opts):

  • :page (Integer)

    Load this page from the image

  • :oneshot (Boolean)

    Load images a frame at a time

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg from file.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg from buffer.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load image from jpeg source.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink factor on load

  • :autorotate (Boolean)

    Rotate image using exif orientation

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg-xl image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg-xl image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load jpeg-xl image.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


.logmat(sigma, min_ampl, **opts) ⇒ Vips::Image

Make a laplacian of gaussian image.

Options Hash (**opts):

  • :separable (Boolean)

    Generate separable Gaussian

  • :precision (Vips::Precision)

    Generate with this precision



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


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

Load file with imagemagick7.

Options Hash (**opts):

  • :density (String)

    Canvas resolution for rendering vector formats like SVG

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load buffer with imagemagick7.

Options Hash (**opts):

  • :density (String)

    Canvas resolution for rendering vector formats like SVG

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load source with imagemagick7.

Options Hash (**opts):

  • :density (String)

    Canvas resolution for rendering vector formats like SVG

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


.mask_butterworth(width, height, order, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image

Make a butterworth filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Make a butterworth_band filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Make a butterworth ring filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Make fractal filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


.mask_gaussian(width, height, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image

Make a gaussian filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Make a gaussian filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


.mask_gaussian_ring(width, height, frequency_cutoff, amplitude_cutoff, ringwidth, **opts) ⇒ Vips::Image

Make a gaussian ring filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Make an ideal filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


.mask_ideal_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, **opts) ⇒ Vips::Image

Make an ideal band filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


.mask_ideal_ring(width, height, frequency_cutoff, ringwidth, **opts) ⇒ Vips::Image

Make an ideal ring filter.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :nodc (Boolean)

    Remove DC component

  • :reject (Boolean)

    Invert the sense of the filter

  • :optical (Boolean)

    Rotate quadrants to optical space



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


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

Load mat from file.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


.matrix_from_array(width, height, array) ⇒ Object

Raises:



475
476
477
478
479
480
481
482
# File 'lib/vips/image.rb', line 475

def self.matrix_from_array width, height, array
  ptr = FFI::MemoryPointer.new :double, array.length
  ptr.write_array_of_double array
  img_ptr = Vips.vips_image_new_matrix_from_array width, height,
    ptr, array.length
  raise Vips::Error if img_ptr.null?
  Vips::Image.new img_ptr
end

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

Load matrix.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load matrix.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Invoke a vips operation with Operation.call.



237
238
239
# File 'lib/vips/image.rb', line 237

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.



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/vips/image.rb', line 510

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

  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.

Options Hash (**opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

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

    Access mode for file

Raises:



321
322
323
324
325
326
# File 'lib/vips/image.rb', line 321

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.

Options Hash (**opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

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

    Access mode for file

Raises:



277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/vips/image.rb', line 277

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.

Raises:



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/vips/image.rb', line 369

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

Raises:



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/vips/image.rb', line 411

def self.new_from_memory_copy data, width, height, bands, format
  format_number = GObject::GValue.enum_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.

Options Hash (**opts):

  • :disc (Boolean) — default: true

    Open large images via a temporary disc file

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

    Access mode for file

Raises:



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

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

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

  # keep a secret ref to the source object ... the libvips loader will
  # keep a ref to the C source object, but we need the ruby wrapper object
  # to stay alive too
  result.references << source

  result
end

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

Load an openexr image.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load file with openslide.

Options Hash (**opts):

  • :level (Integer)

    Load this level from the file

  • :autocrop (Boolean)

    Crop to image bounds

  • :associated (String)

    Load this associated image

  • :attach_associated (Boolean)

    Attach all associated images

  • :rgb (Boolean)

    Output RGB (not RGBA)

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load source with openslide.

Options Hash (**opts):

  • :level (Integer)

    Load this level from the file

  • :autocrop (Boolean)

    Crop to image bounds

  • :associated (String)

    Load this associated image

  • :attach_associated (Boolean)

    Attach all associated images

  • :rgb (Boolean)

    Output RGB (not RGBA)

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load pdf from file (poppler).

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :dpi (Float)

    DPI to render at

  • :scale (Float)

    Factor to scale by

  • :background (Array<Double>)

    Background colour

  • :password (String)

    Password to decrypt with

  • :page_box (Vips::ForeignPdfPageBox)

    The region of the page to render

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load pdf from buffer (poppler).

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :dpi (Float)

    DPI to render at

  • :scale (Float)

    Factor to scale by

  • :background (Array<Double>)

    Background colour

  • :password (String)

    Password to decrypt with

  • :page_box (Vips::ForeignPdfPageBox)

    The region of the page to render

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load pdf from source (poppler).

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :dpi (Float)

    DPI to render at

  • :scale (Float)

    Factor to scale by

  • :background (Array<Double>)

    Background colour

  • :password (String)

    Password to decrypt with

  • :page_box (Vips::ForeignPdfPageBox)

    The region of the page to render

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Make a perlin noise image.

Options Hash (**opts):

  • :cell_size (Integer)

    Size of Perlin cells

  • :uchar (Boolean)

    Output an unsigned char image

  • :seed (Integer)

    Random number seed



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


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

Load png from file.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load png from buffer.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load png from source.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load ppm from file.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load ppm from buffer.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load ppm from source.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


.profile_load(name, **opts) ⇒ VipsBlob

Load named icc profile.



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


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

Load a radiance image from a file.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load rad from buffer.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load rad from source.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load raw data from a file.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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



220
221
222
223
224
225
# File 'lib/vips/image.rb', line 220

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

.run_cmplx(image, &block) ⇒ Object

run a complex operation on a complex image, or an image with an even number of bands ... handy for things like running .polar on .index images



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/vips/image.rb', line 133

def self.run_cmplx image, &block
  original_format = image.format

  unless Image.complex? image.format
    if image.bands % 2 != 0
      raise Vips::Error, "not an even number of bands"
    end

    unless Image.float? image.format
      image = image.cast :float
    end

    new_format = (image.format == :double) ? :dpcomplex : :complex
    image = image.copy format: new_format, bands: image.bands / 2
  end

  image = block.call(image)

  unless Image.complex? original_format
    new_format = (image.format == :dpcomplex) ? :double : :float
    image = image.copy format: new_format, bands: image.bands * 2
  end

  image
end

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

Create an sdf image.

Options Hash (**opts):

  • :r (Float)

    Radius

  • :a (Array<Double>)

    Point a

  • :b (Array<Double>)

    Point b

  • :corners (Array<Double>)

    Corner radii



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


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

Make a 2d sine wave.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image

  • :hfreq (Float)

    Horizontal spatial frequency

  • :vfreq (Float)

    Vertical spatial frequency



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


.smap(x, &block) ⇒ Object

handy for overloads ... want to be able to apply a function to an array or to a scalar



116
117
118
# File 'lib/vips/image.rb', line 116

def self.smap x, &block
  x.is_a?(Array) ? x.map { |y| smap(y, &block) } : block.call(x)
end

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

Sum an array of images.



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


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

Load svg with rsvg.

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :stylesheet (String)

    Custom CSS

  • :high_bitdepth (Boolean)

    Enable scRGB 128-bit output (32-bit per channel)

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load svg with rsvg.

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :stylesheet (String)

    Custom CSS

  • :high_bitdepth (Boolean)

    Enable scRGB 128-bit output (32-bit per channel)

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load svg from source.

Options Hash (**opts):

  • :dpi (Float)

    Render at this DPI

  • :scale (Float)

    Scale output by this factor

  • :unlimited (Boolean)

    Allow SVG of any size

  • :stylesheet (String)

    Custom CSS

  • :high_bitdepth (Boolean)

    Enable scRGB 128-bit output (32-bit per channel)

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

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



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


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

Run an external command.

Options Hash (**opts):

  • :im (Array<Image>)

    Array of input images

  • :in_format (String)

    Format for input filename

  • :out_format (String)

    Format for output filename

  • :cache (Boolean)

    Cache this call

  • :out (Vips::Image)

    Output Output image

  • :log (String)

    Output Command log



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


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

Make a text image.

Options Hash (**opts):

  • :font (String)

    Font to render with

  • :width (Integer)

    Maximum image width in pixels

  • :height (Integer)

    Maximum image height in pixels

  • :align (Vips::Align)

    Align on the low, centre or high edge

  • :justify (Boolean)

    Justify lines

  • :dpi (Integer)

    DPI to render at

  • :spacing (Integer)

    Line spacing

  • :fontfile (String)

    Load this font file

  • :rgba (Boolean)

    Enable RGBA output

  • :wrap (Vips::TextWrap)

    Wrap lines on word or character boundaries

  • :autofit_dpi (Integer)

    Output DPI selected by autofit



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


.thumbnail(filename, width, **opts) ⇒ Vips::Image

Generate thumbnail from file.

Options Hash (**opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

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

  • :input_profile (String)

    Fallback input profile

  • :output_profile (String)

    Fallback output profile

  • :intent (Vips::Intent)

    Rendering intent

  • :fail_on (Vips::FailOn)

    Error level to fail on



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


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

Generate thumbnail from buffer.

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

  • :input_profile (String)

    Fallback input profile

  • :output_profile (String)

    Fallback output profile

  • :intent (Vips::Intent)

    Rendering intent

  • :fail_on (Vips::FailOn)

    Error level to fail on



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


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

Generate thumbnail from source.

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

  • :input_profile (String)

    Fallback input profile

  • :output_profile (String)

    Fallback output profile

  • :intent (Vips::Intent)

    Rendering intent

  • :fail_on (Vips::FailOn)

    Error level to fail on



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


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

Load tiff from file.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :subifd (Integer)

    Subifd index

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load tiff from buffer.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :subifd (Integer)

    Subifd index

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load tiff from source.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :autorotate (Boolean)

    Rotate image using orientation tag

  • :subifd (Integer)

    Subifd index

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Build a look-up table.

Options Hash (**opts):

  • :in_max (Integer)

    Size of LUT to build

  • :out_max (Integer)

    Maximum value in output LUT

  • :Lb (Float)

    Lowest value in output

  • :Lw (Float)

    Highest value in output

  • :Ps (Float)

    Position of shadow

  • :Pm (Float)

    Position of mid-tones

  • :Ph (Float)

    Position of highlights

  • :S (Float)

    Adjust shadows by this much

  • :M (Float)

    Adjust mid-tones by this much

  • :H (Float)

    Adjust highlights by this much



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


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

Load a uhdr image.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load a uhdr image.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load a uhdr image.

Options Hash (**opts):

  • :shrink (Integer)

    Shrink 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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load vips from file.

Options Hash (**opts):

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load vips from source.

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

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load webp from file.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :scale (Float)

    Factor to scale by

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load webp from buffer.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :scale (Float)

    Factor to scale by

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Load webp from source.

Options Hash (**opts):

  • :page (Integer)

    First page to load

  • :n (Integer)

    Number of pages to load, -1 for all

  • :scale (Float)

    Factor to scale by

  • :memory (Boolean)

    Force open via memory

  • :access (Vips::Access)

    Required access pattern for this file

  • :fail_on (Vips::FailOn)

    Error level to fail on

  • :revalidate (Boolean)

    Don't use a cached result for this operation

  • :flags (Vips::ForeignFlags)

    Output Flags for this file



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


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

Make a worley noise image.

Options Hash (**opts):

  • :cell_size (Integer)

    Size of Worley cells

  • :seed (Integer)

    Random number seed



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


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

Make an image where pixel values are coordinates.

Options Hash (**opts):

  • :csize (Integer)

    Size of third dimension

  • :dsize (Integer)

    Size of fourth dimension

  • :esize (Integer)

    Size of fifth dimension



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


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

Make a zone plate.

Options Hash (**opts):

  • :uchar (Boolean)

    Output an unsigned char image



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


Instance Method Details

#!Image

Equivalent to image ^ -1



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

def !
  self ^ -1
end

#!=(other) ⇒ Image

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



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

def != other
  # for equality, we must allow tests against nil
  other.nil? || call_enum("relational", other, :noteq)
end

#%(other) ⇒ Image

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



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

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

#&(other) ⇒ Image

Integer bitwise AND with an image, constant or array.



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

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

#*(other) ⇒ Image

Multiply an image, constant or array.



1055
1056
1057
1058
# File 'lib/vips/image.rb', line 1055

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

#**(other) ⇒ Image

Raise to power of an image, constant or array.



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

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

#+(other) ⇒ Image

Add an image, constant or array.



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

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

#+@Image



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

def +@
  self
end

#-(other) ⇒ Image

Subtract an image, constant or array.



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

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

#-@Image

Equivalent to image * -1



1148
1149
1150
# File 'lib/vips/image.rb', line 1148

def -@
  self * -1
end

#/(other) ⇒ Image

Divide an image, constant or array.



1064
1065
1066
1067
# File 'lib/vips/image.rb', line 1064

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.



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

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

#<<(other) ⇒ Image

Integer left shift with an image, constant or array.



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

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

#<=(other) ⇒ Image

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



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

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

#==(other) ⇒ Image

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



1190
1191
1192
1193
1194
1195
1196
1197
# File 'lib/vips/image.rb', line 1190

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.



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

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

#>=(other) ⇒ Image

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



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

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

#>>(other) ⇒ Image

Integer right shift with an image, constant or array.



1098
1099
1100
# File 'lib/vips/image.rb', line 1098

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

#[](index) ⇒ Image

Fetch bands using a number or a range



1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/vips/image.rb', line 1212

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.



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

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

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

Absolute value of an image.



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


#acosImage

Return the inverse cosine of an image in degrees.



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

def acos
  math :acos
end

#acoshImage

Return the inverse hyperbolic cosine of an image in radians.



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

def acosh
  math :acosh
end

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

Add two images.



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


#add_alphaImage

Append an alpha channel to an image.

Raises:



1003
1004
1005
1006
1007
1008
1009
# File 'lib/vips/image.rb', line 1003

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

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

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

Append an alpha channel.



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


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

Affine transform of an image.

Options Hash (**opts):

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :oarea (Array<Integer>)

    Area of output to generate

  • :odx (Float)

    Horizontal output displacement

  • :ody (Float)

    Vertical output displacement

  • :idx (Float)

    Horizontal input displacement

  • :idy (Float)

    Vertical input displacement

  • :background (Array<Double>)

    Background value

  • :premultiplied (Boolean)

    Images have premultiplied alpha

  • :extend (Vips::Extend)

    How to generate the extra pixels



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


#asinImage

Return the inverse sine of an image in degrees.



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

def asin
  math :asin
end

#asinhImage

Return the inverse hyperbolic sine of an image in radians.



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

def asinh
  math :asinh
end

#atanImage

Return the inverse tangent of an image in degrees.



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

def atan
  math :atan
end

#atanhImage

Return the inverse hyperbolic tangent of an image in radians.



1523
1524
1525
# File 'lib/vips/image.rb', line 1523

def atanh
  math :atanh
end

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

Autorotate image by exif tag.

Options Hash (**opts):

  • :angle (Vips::Angle)

    Output Angle image was rotated by

  • :flip (Boolean)

    Output Whether the image was flipped or not



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


#avg(**opts) ⇒ Float

Find image average.



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


#bandandImage

AND the bands of an image together



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

def bandand
  bandbool :and
end

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

Boolean operation across image bands.



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


#bandeorImage

EOR the bands of an image together



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

def bandeor
  bandbool :eor
end

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

Fold up x axis into bands.

Options Hash (**opts):

  • :factor (Integer)

    Fold by this factor



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


#bandjoin(other) ⇒ Image

Join a set of images bandwise.



1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
# File 'lib/vips/image.rb', line 1312

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

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

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

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

Append a constant band to an image.



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


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

Band-wise average.



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


#bandorImage

OR the bands of an image together



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

def bandor
  bandbool :or
end

#bandsInteger

Get number of image bands.



904
905
906
# File 'lib/vips/image.rb', line 904

def bands
  Vips.vips_image_get_bands self
end

#bandsplitArray<Image>

Split an n-band image into n separate images.



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

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

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

Unfold image bands into x axis.

Options Hash (**opts):

  • :factor (Integer)

    Unfold by this factor



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


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

Boolean operation on two images.



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


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

Boolean operations against a constant.



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


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

Build a look-up table.



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


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

Byteswap an image.



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


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

Canny edge detector.

Options Hash (**opts):

  • :sigma (Float)

    Sigma of Gaussian

  • :precision (Vips::Precision)

    Convolve with this precision



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


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

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



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


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

Cast an image.

Options Hash (**opts):

  • :shift (Boolean)

    Shift integer values up and down



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


#ceilImage

Return the smallest integral value not less than the argument.



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

def ceil
  round :ceil
end

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

Clamp values of an image.

Options Hash (**opts):

  • :min (Float)

    Minimum value

  • :max (Float)

    Maximum value



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


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

Transform lch to cmc.



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


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

Transform cmyk to xyz.



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


#codingSymbol

Get image coding.



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

def coding
  get "coding"
end

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

Convert to a new colorspace.

Options Hash (**opts):



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


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

Convolve with rotating mask.

Options Hash (**opts):

  • :times (Integer)

    Rotate and convolve this many times

  • :angle (Vips::Angle45)

    Rotate mask by this much between convolutions

  • :combine (Vips::Combine)

    Combine convolution results like this

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



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


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

Perform a complex operation on an image.



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


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

Complex binary operations on two images.



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


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

Form a complex image from two real images.



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


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

Get a component from a complex image.



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


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

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

Options Hash (**opts):

  • :x (Array<Integer>)

    x positions of overlay

  • :y (Array<Integer>)

    y positions of overlay

  • :compositing_space (Vips::Interpretation)

    Composite images in this colour space

  • :premultiplied (Boolean)

    Images have premultiplied alpha



1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'lib/vips/image.rb', line 1338

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

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

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

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

Blend a pair of images with a blend mode.

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



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


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



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

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

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

Convolution operation.

Options Hash (**opts):

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



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


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

Approximate integer convolution.

Options Hash (**opts):

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



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


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

Approximate separable integer convolution.

Options Hash (**opts):

  • :layers (Integer)

    Use this many layers in approximation



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


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

Float convolution operation.



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


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

Int convolution operation.



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


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

Separable convolution operation.

Options Hash (**opts):

  • :precision (Vips::Precision)

    Convolve with this precision

  • :layers (Integer)

    Use this many layers in approximation

  • :cluster (Integer)

    Cluster lines closer than this in approximation



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


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

Copy an image.

Options Hash (**opts):

  • :width (Integer)

    Image width in pixels

  • :height (Integer)

    Image height in pixels

  • :bands (Integer)

    Number of bands in image

  • :format (Vips::BandFormat)

    Pixel format in image

  • :coding (Vips::Coding)

    Pixel coding

  • :interpretation (Vips::Interpretation)

    Pixel interpretation

  • :xres (Float)

    Horizontal resolution in pixels/mm

  • :yres (Float)

    Vertical resolution in pixels/mm

  • :xoffset (Integer)

    Horizontal offset of origin

  • :yoffset (Integer)

    Vertical offset of origin



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


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



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

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.



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

def cos
  math :cos
end

#coshImage

Return the hyperbolic cosine of an image in radians.



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

def cosh
  math :cosh
end

#countlines(direction, **opts) ⇒ Float

Count lines in an image.



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


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

Extract an area from an image.



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


#cross_phase(other) ⇒ Image

Calculate the cross phase of two images.



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

def cross_phase other
  complex2 other, :cross_phase
end

#csvsave(filename, **opts) ⇒ nil

Save image to csv.

Options Hash (**opts):

  • :separator (String)

    Separator characters

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#csvsave_target(target, **opts) ⇒ nil

Save image to csv.

Options Hash (**opts):

  • :separator (String)

    Separator characters

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Calculate de00.



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


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

Calculate de76.



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


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

Calculate decmc.



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


#deviate(**opts) ⇒ Float

Find image standard deviation.



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


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



1589
1590
1591
# File 'lib/vips/image.rb', line 1589

def dilate mask
  morph mask, :dilate
end

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

Divide two images.



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


#draw_circle(ink, cx, cy, radius, **opts) ⇒ Vips::Image

Draw a circle on an image.

Options Hash (**opts):

  • :fill (Boolean)

    Draw a solid object



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


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

Flood-fill an area.

Options Hash (**opts):

  • :test (Vips::Image)

    Test pixels in this image

  • :equal (Boolean)

    DrawFlood while equal to edge

  • :left (Integer)

    Output Left edge of modified area

  • :top (Integer)

    Output Top edge of modified area

  • :width (Integer)

    Output Width of modified area

  • :height (Integer)

    Output Height of modified area



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


#draw_image(sub, x, y, **opts) ⇒ Vips::Image

Paint an image into another image.

Options Hash (**opts):

  • :mode (Vips::CombineMode)

    Combining mode



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


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

Draw a line on an image.



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


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

Draw a mask on an image.



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


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

Draw a point on an image.

See #draw_rect.



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

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

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

Paint a rectangle on an image.

Options Hash (**opts):

  • :fill (Boolean)

    Draw a solid object



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


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

Blur a rectangle on an image.



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


#dzsave(filename, **opts) ⇒ nil

Save image to deepzoom file.

Options Hash (**opts):

  • :imagename (String)

    Image name

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

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

  • :id (String)

    Resource ID

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#dzsave_buffer(**opts) ⇒ VipsBlob

Save image to dz buffer.

Options Hash (**opts):

  • :imagename (String)

    Image name

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

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

  • :id (String)

    Resource ID

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#dzsave_target(target, **opts) ⇒ nil

Save image to deepzoom target.

Options Hash (**opts):

  • :imagename (String)

    Image name

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

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

  • :id (String)

    Resource ID

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#embed(x, y, width, height, **opts) ⇒ Vips::Image

Embed an image in a larger image.

Options Hash (**opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels



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


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



1577
1578
1579
# File 'lib/vips/image.rb', line 1577

def erode mask
  morph mask, :erode
end

#expImage

Return e ** pixel.



1544
1545
1546
# File 'lib/vips/image.rb', line 1544

def exp
  math :exp
end

#exp10Image

Return 10 ** pixel.



1551
1552
1553
# File 'lib/vips/image.rb', line 1551

def exp10
  math :exp10
end

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

Extract an area from an image.



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


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

Extract band from an image.

Options Hash (**opts):

  • :n (Integer)

    Number of bands to extract



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


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

False-color an image.



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


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

Fast correlation.



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


#filenameString

Get image filename, if any.



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

def filename
  get "filename"
end

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

Fill image zeros with nearest non-zero pixel.

Options Hash (**opts):

  • :distance (Vips::Image)

    Output Distance to nearest non-zero pixel



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


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

Search an image for non-edge areas.

Options Hash (**opts):

  • :threshold (Float)

    Object threshold

  • :background (Array<Double>)

    Color for background pixels

  • :line_art (Boolean)

    Enable line art mode



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


#fitssave(filename, **opts) ⇒ nil

Save image to fits file.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Flatten alpha out of an image.

Options Hash (**opts):

  • :background (Array<Double>)

    Background value

  • :max_alpha (Float)

    Maximum value of alpha channel



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


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

Flip an image.



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


#fliphorImage

Flip horizontally.



1558
1559
1560
# File 'lib/vips/image.rb', line 1558

def fliphor
  flip :horizontal
end

#flipverImage

Flip vertically.



1565
1566
1567
# File 'lib/vips/image.rb', line 1565

def flipver
  flip :vertical
end

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

Transform float rgb to radiance coding.



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


#floorImage

Return the largest integral value not greater than the argument.



1262
1263
1264
# File 'lib/vips/image.rb', line 1262

def floor
  round :floor
end

#formatSymbol

Get image format.



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

def format
  get "format"
end

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

Frequency-domain filtering.



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


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

Forward fft.



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


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

Gamma an image.

Options Hash (**opts):

  • :exponent (Float)

    Gamma factor



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


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

Gaussian blur.

Options Hash (**opts):

  • :min_ampl (Float)

    Minimum amplitude of Gaussian

  • :precision (Vips::Precision)

    Convolve with this precision



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


#get(name) ⇒ Object

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

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

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

and profile will be an array containing the profile.

Raises:



767
768
769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/vips/image.rb', line 767

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.



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# File 'lib/vips/image.rb', line 786

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_gainmapImage

Get the gainmap (if any) from an image.

After modifying the gainmap, you should write it back to the image in a mutable block, see [#mutate], in the field "gainmap".

For example:

gainmap = image.get_gainmap
unless gainmap.nil?
  new_gainmap = gainmap.crop left, top, width, height
  image = image.mutate do |x|
    x.set_type! Vips::IMAGE_TYPE, "gainmap", new_gainmap
  end
end


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

def get_gainmap
  if Vips.at_least_libvips?(8, 18)
    vi = Vips.vips_image_get_gainmap self
    Image.new(vi) unless vi.null?
  end
end

#get_typeof(name) ⇒ Integer

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

See Also:



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

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



876
877
878
# File 'lib/vips/image.rb', line 876

def get_value name
  get name
end

#getpoint(x, y, **opts) ⇒ Array<Double>

Read a point from an image.

Options Hash (**opts):

  • :unpack_complex (Boolean)

    Complex pixels should be unpacked



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


#gifsave(filename, **opts) ⇒ nil

Save as gif.

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :interframe_maxerror (Float)

    Maximum inter-frame error for transparency

  • :reuse (Boolean)

    Reuse palette from input

  • :interpalette_maxerror (Float)

    Maximum inter-palette error for palette reusage

  • :interlace (Boolean)

    Generate an interlaced (progressive) GIF

  • :keep_duplicate_frames (Boolean)

    Keep duplicate frames in the output instead of combining them

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#gifsave_buffer(**opts) ⇒ VipsBlob

Save as gif.

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :interframe_maxerror (Float)

    Maximum inter-frame error for transparency

  • :reuse (Boolean)

    Reuse palette from input

  • :interpalette_maxerror (Float)

    Maximum inter-palette error for palette reusage

  • :interlace (Boolean)

    Generate an interlaced (progressive) GIF

  • :keep_duplicate_frames (Boolean)

    Keep duplicate frames in the output instead of combining them

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#gifsave_target(target, **opts) ⇒ nil

Save as gif.

Options Hash (**opts):

  • :dither (Float)

    Amount of dithering

  • :effort (Integer)

    Quantisation effort

  • :bitdepth (Integer)

    Number of bits per pixel

  • :interframe_maxerror (Float)

    Maximum inter-frame error for transparency

  • :reuse (Boolean)

    Reuse palette from input

  • :interpalette_maxerror (Float)

    Maximum inter-palette error for palette reusage

  • :interlace (Boolean)

    Generate an interlaced (progressive) GIF

  • :keep_duplicate_frames (Boolean)

    Keep duplicate frames in the output instead of combining them

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Global balance an image mosaic.

Options Hash (**opts):

  • :gamma (Float)

    Image gamma

  • :int_output (Boolean)

    Integer output



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


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

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

Options Hash (**opts):

  • :extend (Vips::Extend)

    How to generate the extra pixels

  • :background (Array<Double>)

    Color for background pixels



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


#grid(tile_height, across, down, **opts) ⇒ Vips::Image

Grid an image.



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


#has_alpha?Boolean

Detect if image has an alpha channel



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

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

#heifsave(filename, **opts) ⇒ nil

Save image in heif format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :bitdepth (Integer)

    Number of bits per pixel

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :encoder (Vips::ForeignHeifEncoder)

    Select encoder to use

  • :tune (String)

    Tuning parameters

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#heifsave_buffer(**opts) ⇒ VipsBlob

Save image in heif format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :bitdepth (Integer)

    Number of bits per pixel

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :encoder (Vips::ForeignHeifEncoder)

    Select encoder to use

  • :tune (String)

    Tuning parameters

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#heifsave_target(target, **opts) ⇒ nil

Save image in heif format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :bitdepth (Integer)

    Number of bits per pixel

  • :lossless (Boolean)

    Enable lossless compression

  • :compression (Vips::ForeignHeifCompression)

    Compression format

  • :effort (Integer)

    CPU effort

  • :subsample_mode (Vips::ForeignSubsample)

    Select chroma subsample operation mode

  • :encoder (Vips::ForeignHeifEncoder)

    Select encoder to use

  • :tune (String)

    Tuning parameters

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#heightInteger

Get image height, in pixels.



897
898
899
# File 'lib/vips/image.rb', line 897

def height
  Vips.vips_image_get_height self
end

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

Form cumulative histogram.



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


#hist_entropy(**opts) ⇒ Float

Estimate image entropy.



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


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

Histogram equalisation.

Options Hash (**opts):

  • :band (Integer)

    Equalise with this band



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


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

Find image histogram.

Options Hash (**opts):

  • :band (Integer)

    Find histogram of band



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


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

Find indexed image histogram.

Options Hash (**opts):



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


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

Find n-dimensional image histogram.

Options Hash (**opts):

  • :bins (Integer)

    Number of bins in each dimension



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


#hist_ismonotonic(**opts) ⇒ Boolean

Test for monotonicity.



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


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

Local histogram equalisation.

Options Hash (**opts):

  • :max_slope (Integer)

    Maximum slope (CLAHE)



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


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

Match two histograms.



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


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

Normalise histogram.



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


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

Plot histogram.



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


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

Find hough circle transform.

Options Hash (**opts):

  • :scale (Integer)

    Scale down dimensions by this factor

  • :min_radius (Integer)

    Smallest radius to search for

  • :max_radius (Integer)

    Largest radius to search for



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


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

Find hough line transform.

Options Hash (**opts):

  • :width (Integer)

    Horizontal size of parameter space

  • :height (Integer)

    Vertical size of parameter space



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


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

Transform hsv to srgb.



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


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

Output to device with icc profile.

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

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



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


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

Import from device with icc profile.

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

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



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


#icc_transform(output_profile, **opts) ⇒ Vips::Image

Transform between devices with icc profiles.

Options Hash (**opts):

  • :pcs (Vips::PCS)

    Set Profile Connection Space

  • :intent (Vips::Intent)

    Rendering intent

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



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


#ifthenelse(th, el, **opts) ⇒ Image

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

Options Hash (**opts):

  • :blend (Boolean) — default: false

    Blend smoothly between th and el



1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
# File 'lib/vips/image.rb', line 1623

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.



1393
1394
1395
# File 'lib/vips/image.rb', line 1393

def imag
  complexget :imag
end

#insert(sub, x, y, **opts) ⇒ Vips::Image

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

Options Hash (**opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :background (Array<Double>)

    Color for new pixels



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


#inspectObject



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

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

#interpretationSymbol

Get image interpretation.



918
919
920
# File 'lib/vips/image.rb', line 918

def interpretation
  get "interpretation"
end

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

Invert an image.



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


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

Build an inverted look-up table.

Options Hash (**opts):

  • :size (Integer)

    LUT size to generate



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


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

Inverse fft.

Options Hash (**opts):

  • :real (Boolean)

    Output only the real part of the transform



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


#join(in2, direction, **opts) ⇒ Vips::Image

Join a pair of images.

Options Hash (**opts):

  • :expand (Boolean)

    Expand output to hold all of both inputs

  • :shim (Integer)

    Pixels between images

  • :background (Array<Double>)

    Colour for new pixels

  • :align (Vips::Align)

    Align on the low, centre or high coordinate edge



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


#jp2ksave(filename, **opts) ⇒ nil

Save image in jpeg2000 format.

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jp2ksave_buffer(**opts) ⇒ VipsBlob

Save image in jpeg2000 format.

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jp2ksave_target(target, **opts) ⇒ nil

Save image in jpeg2000 format.

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jpegsave(filename, **opts) ⇒ nil

Save as jpeg.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jpegsave_buffer(**opts) ⇒ VipsBlob

Save as jpeg.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jpegsave_mime(**opts) ⇒ nil

Save image to jpeg mime.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jpegsave_target(target, **opts) ⇒ nil

Save as jpeg.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jxlsave(filename, **opts) ⇒ nil

Save image in jpeg-xl format.

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

  • :bitdepth (Integer)

    Bit depth

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jxlsave_buffer(**opts) ⇒ VipsBlob

Save image in jpeg-xl format.

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

  • :bitdepth (Integer)

    Bit depth

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#jxlsave_target(target, **opts) ⇒ nil

Save image in jpeg-xl format.

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

  • :bitdepth (Integer)

    Bit depth

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Transform float lab to labq coding.



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


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

Transform float lab to signed short.



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


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

Transform lab to lch.



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


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

Transform cielab to xyz.

Options Hash (**opts):

  • :temp (Array<Double>)

    Color temperature



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


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

Label regions in an image.

Options Hash (**opts):

  • :segments (Integer)

    Output Number of discrete contiguous regions



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


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

Unpack a labq image to float lab.



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


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

Unpack a labq image to short lab.



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


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

Convert a labq image to srgb.



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


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

Transform signed short lab to float.



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


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

Transform short lab to labq coding.



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


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

Transform lch to cmc.



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


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

Transform lch to lab.



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


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

Calculate (a * in + b).

Options Hash (**opts):

  • :uchar (Boolean)

    Output should be uchar



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


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

Cache an image as a set of lines.

Options Hash (**opts):

  • :tile_height (Integer)

    Tile height in pixels

  • :access (Vips::Access)

    Expected access pattern

  • :threaded (Boolean)

    Allow threaded access

  • :persistent (Boolean)

    Keep cache between evaluations



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


#logImage

Return the natural log of an image.



1530
1531
1532
# File 'lib/vips/image.rb', line 1530

def log
  math :log
end

#log10Image

Return the log base 10 of an image.



1537
1538
1539
# File 'lib/vips/image.rb', line 1537

def log10
  math :log10
end

#magicksave(filename, **opts) ⇒ nil

Save file with imagemagick.

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

  • :bitdepth (Integer)

    Number of bits per pixel

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#magicksave_buffer(**opts) ⇒ VipsBlob

Save image to magick buffer.

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

  • :bitdepth (Integer)

    Number of bits per pixel

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Resample with a map image.

Options Hash (**opts):

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :background (Array<Double>)

    Background value

  • :premultiplied (Boolean)

    Images have premultiplied alpha

  • :extend (Vips::Extend)

    How to generate the extra pixels



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


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

Map an image though a lut.

Options Hash (**opts):

  • :band (Integer)

    Apply one-band lut to this band of in



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


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

First-order match of two images.

Options Hash (**opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :search (Boolean)

    Search to improve tie-points

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this



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


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

Apply a math operation to an image.



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


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

Binary math operations.



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


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

Binary math operations with a constant.



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


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

Invert a matrix.



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


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

Multiply two matrices.



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


#matrixprint(**opts) ⇒ nil

Print matrix.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#matrixsave(filename, **opts) ⇒ nil

Save image to matrix.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#matrixsave_target(target, **opts) ⇒ nil

Save image to matrix.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Find image maximum.

Options Hash (**opts):

  • :size (Integer)

    Number of maximum values to find

  • :x (Integer)

    Output Horizontal position of maximum

  • :y (Integer)

    Output Vertical position of maximum

  • :out_array (Array<Double>)

    Output Array of output values

  • :x_array (Array<Integer>)

    Output Array of horizontal positions

  • :y_array (Array<Integer>)

    Output Array of vertical positions



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


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

Maximum of a pair of images.



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


#maxposReal

Return the coordinates of the image maximum.



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

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.

Options Hash (**opts):

  • :left (Integer)

    Left edge of extract area

  • :top (Integer)

    Top edge of extract area

  • :width (Integer)

    Width of extract area

  • :height (Integer)

    Height of extract area



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


#median(size = 3) ⇒ Image

a median filter



1379
1380
1381
# File 'lib/vips/image.rb', line 1379

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

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

Merge two images.

Options Hash (**opts):

  • :mblend (Integer)

    Maximum blend size



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


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

Find image minimum.

Options Hash (**opts):

  • :size (Integer)

    Number of minimum values to find

  • :x (Integer)

    Output Horizontal position of minimum

  • :y (Integer)

    Output Vertical position of minimum

  • :out_array (Array<Double>)

    Output Array of output values

  • :x_array (Array<Integer>)

    Output Array of horizontal positions

  • :y_array (Array<Integer>)

    Output Array of vertical positions



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


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

Minimum of a pair of images.



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


#minposReal

Return the coordinates of the image minimum.



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

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.



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


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

Mosaic two images.

Options Hash (**opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :mblend (Integer)

    Maximum blend size

  • :bandno (Integer)

    Band to search for features on

  • :dx0 (Integer)

    Output Detected integer offset

  • :dy0 (Integer)

    Output Detected integer offset

  • :scale1 (Float)

    Output Detected scale

  • :angle1 (Float)

    Output Detected rotation

  • :dy1 (Float)

    Output Detected first-order displacement

  • :dx1 (Float)

    Output Detected first-order displacement



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


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

First-order mosaic of two images.

Options Hash (**opts):

  • :hwindow (Integer)

    Half window size

  • :harea (Integer)

    Half area size

  • :search (Boolean)

    Search to improve tie-points

  • :interpolate (Vips::Interpolate)

    Interpolate pixels with this

  • :mblend (Integer)

    Maximum blend size



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


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

Pick most-significant byte from an image.

Options Hash (**opts):

  • :band (Integer)

    Band to msb



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


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

Multiply two images.



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


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


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

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.



559
560
561
562
563
564
# File 'lib/vips/image.rb', line 559

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

#offsetFloat

Get offset metadata.



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

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

  get "offset"
end

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

Transform oklab to oklch.



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


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

Transform oklab to xyz.



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


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

Transform oklch to oklab.



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


#parent_get_typeofObject



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

alias_method :parent_get_typeof, :get_typeof

#percent(percent, **opts) ⇒ Integer

Find threshold for percent of pixels.



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


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

Calculate phase correlation.



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


#pngsave(filename, **opts) ⇒ nil

Save image to file as png.

Options Hash (**opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :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, 8 or 16 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#pngsave_buffer(**opts) ⇒ VipsBlob

Save image to buffer as png.

Options Hash (**opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :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, 8 or 16 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#pngsave_target(target, **opts) ⇒ nil

Save image to target as png.

Options Hash (**opts):

  • :compression (Integer)

    Compression factor

  • :interlace (Boolean)

    Interlace image

  • :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, 8 or 16 bit image

  • :effort (Integer)

    Quantisation CPU effort

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#polarImage

Return an image with rectangular pixels converted to polar.

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

See Also:



1406
1407
1408
# File 'lib/vips/image.rb', line 1406

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

#ppmsave(filename, **opts) ⇒ nil

Save image to ppm file.

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#ppmsave_target(target, **opts) ⇒ nil

Save to ppm.

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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Premultiply image alpha.

Options Hash (**opts):

  • :max_alpha (Float)

    Maximum value of alpha channel



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


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

Prewitt edge detector.



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


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

Find image profiles.



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


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

Find image projections.



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


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

Resample an image with a quadratic transform.

Options Hash (**opts):



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


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

Unpack radiance coding to float rgb.



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


#radsave(filename, **opts) ⇒ nil

Save image to radiance file.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#radsave_buffer(**opts) ⇒ VipsBlob

Save image to radiance buffer.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#radsave_target(target, **opts) ⇒ nil

Save image to radiance target.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Rank filter.



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


#rawsave(filename, **opts) ⇒ nil

Save image to raw file.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#rawsave_buffer(**opts) ⇒ VipsBlob

Write raw image to buffer.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#rawsave_target(target, **opts) ⇒ nil

Write raw image to target.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#realImage

Return the real part of a complex image.



1386
1387
1388
# File 'lib/vips/image.rb', line 1386

def real
  complexget :real
end

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

Linear recombination with matrix.



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


#rectImage

Return an image with polar pixels converted to rectangular.

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

See Also:



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

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

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

Reduce an image.

Options Hash (**opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :gap (Float)

    Reducing gap



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


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

Shrink an image horizontally.

Options Hash (**opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :gap (Float)

    Reducing gap



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


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

Shrink an image vertically.

Options Hash (**opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :gap (Float)

    Reducing gap



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


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

Relational operation on two images.



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


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

Relational operations against a constant.



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


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

Remainder after integer division of two images.



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


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

Remainder after integer division of an image and a constant.



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


#remosaic(old_str, new_str, **opts) ⇒ Vips::Image

Rebuild an mosaiced image.



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


#remove(name) ⇒ Object

This method is deprecated.

Please use MutableImage#remove! instead.



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

def remove name
  Vips.vips_image_remove self, name
end

#replicate(across, down, **opts) ⇒ Vips::Image

Replicate an image.



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


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

Resize an image.

Options Hash (**opts):

  • :kernel (Vips::Kernel)

    Resampling kernel

  • :gap (Float)

    Reducing gap

  • :vscale (Float)

    Vertical scale image by this factor



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


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



202
203
204
205
206
207
208
209
210
211
# File 'lib/vips/image.rb', line 202

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



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

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.



1276
1277
1278
# File 'lib/vips/image.rb', line 1276

def rint
  round :rint
end

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

Rotate an image.



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


#rot180Image

Rotate by 180 degrees clockwise.



1603
1604
1605
# File 'lib/vips/image.rb', line 1603

def rot180
  rot :d180
end

#rot270Image

Rotate by 270 degrees clockwise.



1610
1611
1612
# File 'lib/vips/image.rb', line 1610

def rot270
  rot :d270
end

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

Rotate an image.

Options Hash (**opts):



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


#rot90Image

Rotate by 90 degrees clockwise.



1596
1597
1598
# File 'lib/vips/image.rb', line 1596

def rot90
  rot :d90
end

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

Rotate an image by a number of degrees.

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



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


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

Perform a round function on an image.



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


#scaleFloat

Get scale metadata.



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

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

  get "scale"
end

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

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



1641
1642
1643
# File 'lib/vips/image.rb', line 1641

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

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

Scharr edge detector.



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


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

Convert scrgb to bw.

Options Hash (**opts):

  • :depth (Integer)

    Output device space depth in bits



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


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

Convert scrgb to srgb.

Options Hash (**opts):

  • :depth (Integer)

    Output device space depth in bits



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


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

Transform scrgb to xyz.



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


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

Check sequential access.

Options Hash (**opts):

  • :tile_height (Integer)

    Tile height in pixels



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


#set(name, value) ⇒ Object

This method is deprecated.

Please use MutableImage#set! instead.



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

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.



733
734
735
# File 'lib/vips/image.rb', line 733

def set_kill kill
  Vips.vips_image_set_kill(self, kill ? 1 : 0)
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.



722
723
724
# File 'lib/vips/image.rb', line 722

def set_progress state
  Vips.vips_image_set_progress(self, state ? 1 : 0)
end

#set_type(gtype, name, value) ⇒ Object

This method is deprecated.

Please use MutableImage#set_type! instead.



853
854
855
856
857
858
859
# File 'lib/vips/image.rb', line 853

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.



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

def set_value name, value
  set name, value
end

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

Unsharp masking for print.

Options Hash (**opts):

  • :sigma (Float)

    Sigma of Gaussian

  • :x1 (Float)

    Flat/jaggy threshold

  • :y2 (Float)

    Maximum brightening

  • :y3 (Float)

    Maximum darkening

  • :m1 (Float)

    Slope for flat areas

  • :m2 (Float)

    Slope for jaggy areas



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


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

Shrink an image.

Options Hash (**opts):

  • :ceil (Boolean)

    Round-up output dimensions



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


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

Shrink an image horizontally.

Options Hash (**opts):

  • :ceil (Boolean)

    Round-up output dimensions



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


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

Shrink an image vertically.

Options Hash (**opts):

  • :ceil (Boolean)

    Round-up output dimensions



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


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

Unit vector of pixel.



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


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

Similarity transform of an image.

Options Hash (**opts):

  • :scale (Float)

    Scale by this factor

  • :angle (Float)

    Rotate clockwise 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



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


#sinImage

Return the sine of an image in degrees.



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

def sin
  math :sin
end

#sinhImage

Return the hyperbolic sine of an image in radians.



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

def sinh
  math :sinh
end

#sizeInteger

Get the image size.



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

def size
  [width, height]
end

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

Extract an area from an image.

Options Hash (**opts):

  • :interesting (Vips::Interesting)

    How to measure interestingness

  • :premultiplied (Boolean)

    Input image already has premultiplied alpha

  • :attention_x (Integer)

    Output Horizontal position of attention centre

  • :attention_y (Integer)

    Output Vertical position of attention centre



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


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

Sobel edge detector.



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


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

Spatial correlation.



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


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

Make displayable power spectrum.



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


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

Transform srgb to hsv.



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


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

Convert an srgb image to scrgb.



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


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

Find many image stats.



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


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

Statistical difference.

Options Hash (**opts):

  • :s0 (Float)

    New deviation

  • :b (Float)

    Weight of new deviation

  • :m0 (Float)

    New mean

  • :a (Float)

    Weight of new mean



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


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

Subsample an image.

Options Hash (**opts):

  • :point (Boolean)

    Point sample



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


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

Subtract two images.



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


#tanImage

Return the tangent of an image in degrees.



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

def tan
  math :tan
end

#tanhImage

Return the hyperbolic tangent of an image in radians.



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

def tanh
  math :tanh
end

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

Generate thumbnail from image.

Options Hash (**opts):

  • :height (Integer)

    Size to this height

  • :size (Vips::Size)

    Only upsize, only downsize, or both

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

  • :input_profile (String)

    Fallback input profile

  • :output_profile (String)

    Fallback output profile

  • :intent (Vips::Intent)

    Rendering intent

  • :fail_on (Vips::FailOn)

    Error level to fail on



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


#tiffsave(filename, **opts) ⇒ nil

Save image to tiff file.

Options Hash (**opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

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

    Deflate (1-9, default 6) or ZSTD (1-22, default 9) 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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#tiffsave_buffer(**opts) ⇒ VipsBlob

Save image to tiff buffer.

Options Hash (**opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

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

    Deflate (1-9, default 6) or ZSTD (1-22, default 9) 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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#tiffsave_target(target, **opts) ⇒ nil

Save image to tiff target.

Options Hash (**opts):

  • :compression (Vips::ForeignTiffCompression)

    Compression for this file

  • :Q (Integer)

    Q factor

  • :predictor (Vips::ForeignTiffPredictor)

    Compression prediction

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

    Deflate (1-9, default 6) or ZSTD (1-22, default 9) 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

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Cache an image as a set of tiles.

Options Hash (**opts):

  • :tile_width (Integer)

    Tile width in pixels

  • :tile_height (Integer)

    Tile height in pixels

  • :max_tiles (Integer)

    Maximum number of tiles to cache

  • :access (Vips::Access)

    Expected access pattern

  • :threaded (Boolean)

    Allow threaded access

  • :persistent (Boolean)

    Keep cache between evaluations



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


#to_aArray

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



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

def to_a
  to_enum.to_a
end

#to_enumEnumerator

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



1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
# File 'lib/vips/image.rb', line 1226

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.

Options Hash (**opts):

  • :page_height (Integer)

    Height of each input page



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


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

Transform uhdr to scrgb.



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


#uhdrsave(filename, **opts) ⇒ nil

Save image in ultrahdr format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#uhdrsave_buffer(**opts) ⇒ VipsBlob

Save image in ultrahdr format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#uhdrsave_target(target, **opts) ⇒ nil

Save image in ultrahdr format.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


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

Unpremultiply image alpha.

Options Hash (**opts):

  • :max_alpha (Float)

    Maximum value of alpha channel

  • :alpha_band (Integer)

    Unpremultiply with this alpha



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


#vipssave(filename, **opts) ⇒ nil

Save image to file in vips format.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#vipssave_target(target, **opts) ⇒ nil

Save image to target in vips format.

Options Hash (**opts):

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#webpsave(filename, **opts) ⇒ nil

Save as webp.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :exact (Boolean)

    Preserve color values from transparent pixels

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

  • :target_size (Integer)

    Desired target size in bytes

  • :mixed (Boolean)

    Allow mixed encoding (might reduce file size)

  • :smart_deblock (Boolean)

    Enable auto-adjusting of the deblocking filter

  • :passes (Integer)

    Number of entropy-analysis passes (in [1..10])

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#webpsave_buffer(**opts) ⇒ VipsBlob

Save as webp.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :exact (Boolean)

    Preserve color values from transparent pixels

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

  • :target_size (Integer)

    Desired target size in bytes

  • :mixed (Boolean)

    Allow mixed encoding (might reduce file size)

  • :smart_deblock (Boolean)

    Enable auto-adjusting of the deblocking filter

  • :passes (Integer)

    Number of entropy-analysis passes (in [1..10])

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#webpsave_mime(**opts) ⇒ nil

Save image to webp mime.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :exact (Boolean)

    Preserve color values from transparent pixels

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

  • :target_size (Integer)

    Desired target size in bytes

  • :mixed (Boolean)

    Allow mixed encoding (might reduce file size)

  • :smart_deblock (Boolean)

    Enable auto-adjusting of the deblocking filter

  • :passes (Integer)

    Number of entropy-analysis passes (in [1..10])

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#webpsave_target(target, **opts) ⇒ nil

Save as webp.

Options Hash (**opts):

  • :Q (Integer)

    Q factor

  • :lossless (Boolean)

    Enable lossless compression

  • :exact (Boolean)

    Preserve color values from transparent pixels

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

  • :target_size (Integer)

    Desired target size in bytes

  • :mixed (Boolean)

    Allow mixed encoding (might reduce file size)

  • :smart_deblock (Boolean)

    Enable auto-adjusting of the deblocking filter

  • :passes (Integer)

    Number of entropy-analysis passes (in [1..10])

  • :keep (Vips::ForeignKeep)

    Which metadata to retain

  • :background (Array<Double>)

    Background value

  • :page_height (Integer)

    Set page height for multipage save

  • :profile (String)

    Filename of ICC profile to embed



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


#widthInteger

Get image width, in pixels.



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

def width
  Vips.vips_image_get_width self
end

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

Wrap image origin.

Options Hash (**opts):

  • :x (Integer)

    Left edge of input in output

  • :y (Integer)

    Top edge of input in output



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


#write_to_buffer(format_string, **opts) ⇒ String

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

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

or equivalently:

image.write_to_buffer ".jpg", Q: 90

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

$ vips jpegsave

to see all the available options for JPEG save.

Options Hash (**opts):

  • :strip (Boolean) — default: false

    Strip all metadata from image

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

    Background colour to flatten alpha against, if necessary

Raises:



633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/vips/image.rb', line 633

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

  write_gc

  buffer
end

#write_to_file(name, **opts) ⇒ Object

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

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

or equivalently:

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

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

$ vips jpegsave

to see all the available options for JPEG save.

Options Hash (**opts):

  • :strip (Boolean) — default: false

    Strip all metadata from image

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

    Background colour to flatten alpha against, if necessary

Raises:



595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/vips/image.rb', line 595

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

  write_gc
end

#write_to_memoryString

Write this image to a large memory buffer.

Raises:



704
705
706
707
708
709
710
711
712
713
# File 'lib/vips/image.rb', line 704

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

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

  ptr.get_bytes 0, len[:value]
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.

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:



690
691
692
693
694
695
696
697
698
699
# File 'lib/vips/image.rb', line 690

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
  write_gc
end

#xoffsetInteger

Get image xoffset.



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

def xoffset
  get "xoffset"
end

#xresFloat

Get image x resolution.



953
954
955
# File 'lib/vips/image.rb', line 953

def xres
  get "xres"
end

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

Transform xyz to cmyk.



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


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

Transform xyz to lab.

Options Hash (**opts):

  • :temp (Array<Double>)

    Colour temperature



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


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

Transform xyz to oklab.



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


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

Transform xyz to scrgb.



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


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

Transform xyz to yxy.



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


#yoffsetInteger

Get image yoffset.



946
947
948
# File 'lib/vips/image.rb', line 946

def yoffset
  get "yoffset"
end

#yresFloat

Get image y resolution.



960
961
962
# File 'lib/vips/image.rb', line 960

def yres
  get "yres"
end

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

Transform yxy to xyz.



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


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

Zoom an image.



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


#|(other) ⇒ Image

Integer bitwise OR with an image, constant or array.



1106
1107
1108
# File 'lib/vips/image.rb', line 1106

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

#~Image

Equivalent to image ^ -1



1136
1137
1138
# File 'lib/vips/image.rb', line 1136

def ~
  self ^ -1
end