Class: Vips::Image
- Inherits:
-
Object
- Object
- GObject::GObject
- Object
- Vips::Image
- 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
Class Method Summary collapse
-
.analyzeload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load an analyze6 image.
-
.arrayjoin(im, **opts) ⇒ Vips::Image
Join an array of images.
-
.bandrank(im, **opts) ⇒ Vips::Image
Band-wise rank of a set of images.
-
.black(width, height, **opts) ⇒ Vips::Image
Make a black image.
-
.csvload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load csv.
-
.csvload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load csv.
-
.eye(width, height, **opts) ⇒ Vips::Image
Make an image showing the eye's spatial response.
-
.fitsload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a fits image.
-
.fitsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load fits from a source.
-
.fractsurf(width, height, fractal_dimension, **opts) ⇒ Vips::Image
Make a fractal surface.
-
.gaussmat(sigma, min_ampl, **opts) ⇒ Vips::Image
Make a gaussian image.
-
.gaussnoise(width, height, **opts) ⇒ Vips::Image
Make a gaussnoise image.
-
.gifload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif with libnsgif.
-
.gifload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif with libnsgif.
-
.gifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif from source.
-
.grey(width, height, **opts) ⇒ Vips::Image
Make a grey ramp image.
-
.heifload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
-
.heifload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
-
.heifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
-
.identity(**opts) ⇒ Vips::Image
Make a 1d image where pixel values are indexes.
-
.jp2kload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
-
.jp2kload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
-
.jp2kload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
-
.jpegload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg from file.
-
.jpegload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg from buffer.
-
.jpegload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load image from jpeg source.
-
.jxlload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
-
.jxlload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
-
.jxlload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
-
.logmat(sigma, min_ampl, **opts) ⇒ Vips::Image
Make a laplacian of gaussian image.
-
.magickload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load file with imagemagick.
-
.magickload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load buffer with imagemagick.
-
.mask_butterworth(width, height, order, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a butterworth filter.
-
.mask_butterworth_band(width, height, order, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a butterworth_band filter.
-
.mask_butterworth_ring(width, height, order, frequency_cutoff, amplitude_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make a butterworth ring filter.
-
.mask_fractal(width, height, fractal_dimension, **opts) ⇒ Vips::Image
Make fractal filter.
-
.mask_gaussian(width, height, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a gaussian filter.
-
.mask_gaussian_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a gaussian filter.
-
.mask_gaussian_ring(width, height, frequency_cutoff, amplitude_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make a gaussian ring filter.
-
.mask_ideal(width, height, frequency_cutoff, **opts) ⇒ Vips::Image
Make an ideal filter.
-
.mask_ideal_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, **opts) ⇒ Vips::Image
Make an ideal band filter.
-
.mask_ideal_ring(width, height, frequency_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make an ideal ring filter.
-
.matload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load mat from file.
- .matrix_from_array(width, height, array) ⇒ Object
-
.matrixload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load matrix.
-
.matrixload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load matrix.
-
.method_missing(name, *args, **options) ⇒ Object
Invoke a vips operation with Operation.call.
-
.new_from_array(array, scale = 1, offset = 0) ⇒ Image
Create a new Image from a 1D or 2D array.
-
.new_from_buffer(data, option_string, **opts) ⇒ Image
Create a new Image for an image encoded in a format such as JPEG in a binary string.
-
.new_from_file(name, **opts) ⇒ Image
Return a new Image for a file on disc.
-
.new_from_memory(data, width, height, bands, format) ⇒ Image
Create a new Image from a C-style array held in memory.
-
.new_from_memory_copy(data, width, height, bands, format) ⇒ Image
Create a new Image from memory and copies the memory area.
-
.new_from_source(source, option_string, **opts) ⇒ Image
Create a new Image from a source.
-
.niftiload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load nifti volume.
-
.niftiload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load nifti volumes.
-
.openexrload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load an openexr image.
-
.openslideload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load file with openslide.
-
.openslideload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load source with openslide.
-
.pdfload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from file.
-
.pdfload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from buffer.
-
.pdfload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from source.
-
.perlin(width, height, **opts) ⇒ Vips::Image
Make a perlin noise image.
-
.pngload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from file.
-
.pngload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from buffer.
-
.pngload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from source.
-
.ppmload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load ppm from file.
-
.ppmload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load ppm base class.
-
.profile_load(name, **opts) ⇒ VipsBlob
Load named icc profile.
-
.radload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a radiance image from a file.
-
.radload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load rad from buffer.
-
.radload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load rad from source.
-
.rawload(filename, width, height, bands, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load raw data from a file.
- .respond_to_missing?(name, include_all = false) ⇒ Boolean
-
.sines(width, height, **opts) ⇒ Vips::Image
Make a 2d sine wave.
-
.sum(im, **opts) ⇒ Vips::Image
Sum an array of images.
-
.svgload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg with rsvg.
-
.svgload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg with rsvg.
-
.svgload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg from source.
-
.switch(tests, **opts) ⇒ Vips::Image
Find the index of the first non-zero pixel in tests.
-
.system(cmd_format, **opts) ⇒ nil, Hash<Symbol => Object>
Run an external command.
-
.text(text, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Make a text image.
-
.thumbnail(filename, width, **opts) ⇒ Vips::Image
Generate thumbnail from file.
-
.thumbnail_buffer(buffer, width, **opts) ⇒ Vips::Image
Generate thumbnail from buffer.
-
.thumbnail_source(source, width, **opts) ⇒ Vips::Image
Generate thumbnail from source.
-
.tiffload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from file.
-
.tiffload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from buffer.
-
.tiffload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from source.
-
.tonelut(**opts) ⇒ Vips::Image
Build a look-up table.
-
.vipsload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load vips from file.
-
.vipsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load vips from source.
-
.webpload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from file.
-
.webpload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from buffer.
-
.webpload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from source.
-
.worley(width, height, **opts) ⇒ Vips::Image
Make a worley noise image.
-
.xyz(width, height, **opts) ⇒ Vips::Image
Make an image where pixel values are coordinates.
-
.zone(width, height, **opts) ⇒ Vips::Image
Make a zone plate.
Instance Method Summary collapse
-
#! ⇒ Image
Equivalent to image ^ -1.
-
#!=(other) ⇒ Image
Compare inequality to nil, an image, constant or array.
-
#%(other) ⇒ Image
Remainder after integer division with an image, constant or array.
-
#&(other) ⇒ Image
Integer bitwise AND with an image, constant or array.
-
#*(other) ⇒ Image
Multiply an image, constant or array.
-
#**(other) ⇒ Image
Raise to power of an image, constant or array.
-
#+(other) ⇒ Image
Add an image, constant or array.
-
#+@ ⇒ Image
Image.
-
#-(other) ⇒ Image
Subtract an image, constant or array.
-
#-@ ⇒ Image
Equivalent to image * -1.
-
#/(other) ⇒ Image
Divide an image, constant or array.
-
#<(other) ⇒ Image
Relational less than with an image, constant or array.
-
#<<(other) ⇒ Image
Integer left shift with an image, constant or array.
-
#<=(other) ⇒ Image
Relational less than or equal to with an image, constant or array.
-
#==(other) ⇒ Image
Compare equality to nil, an image, constant or array.
-
#>(other) ⇒ Image
Relational more than with an image, constant or array.
-
#>=(other) ⇒ Image
Relational more than or equal to with an image, constant or array.
-
#>>(other) ⇒ Image
Integer right shift with an image, constant or array.
-
#[](index) ⇒ Image
Fetch bands using a number or a range.
-
#^(other) ⇒ Image
Integer bitwise EOR with an image, constant or array.
-
#abs(**opts) ⇒ Vips::Image
Absolute value of an image.
-
#acos ⇒ Image
Return the inverse cosine of an image in degrees.
-
#add(right, **opts) ⇒ Vips::Image
Add two images.
-
#add_alpha ⇒ Image
Append an alpha channel to an image.
-
#affine(matrix, **opts) ⇒ Vips::Image
Affine transform of an image.
-
#asin ⇒ Image
Return the inverse sine of an image in degrees.
-
#atan ⇒ Image
Return the inverse tangent of an image in degrees.
-
#autorot(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Autorotate image by exif tag.
-
#avg(**opts) ⇒ Float
Find image average.
-
#bandand ⇒ Image
AND the bands of an image together.
-
#bandbool(boolean, **opts) ⇒ Vips::Image
Boolean operation across image bands.
-
#bandeor ⇒ Image
EOR the bands of an image together.
-
#bandfold(**opts) ⇒ Vips::Image
Fold up x axis into bands.
-
#bandjoin(other) ⇒ Image
Join a set of images bandwise.
-
#bandjoin_const(c, **opts) ⇒ Vips::Image
Append a constant band to an image.
-
#bandmean(**opts) ⇒ Vips::Image
Band-wise average.
-
#bandor ⇒ Image
OR the bands of an image together.
-
#bands ⇒ Integer
Get number of image bands.
-
#bandsplit ⇒ Array<Image>
Split an n-band image into n separate images.
-
#bandunfold(**opts) ⇒ Vips::Image
Unfold image bands into x axis.
-
#boolean(right, boolean, **opts) ⇒ Vips::Image
Boolean operation on two images.
-
#boolean_const(boolean, c, **opts) ⇒ Vips::Image
Boolean operations against a constant.
-
#buildlut(**opts) ⇒ Vips::Image
Build a look-up table.
-
#byteswap(**opts) ⇒ Vips::Image
Byteswap an image.
-
#cache(**opts) ⇒ Vips::Image
Cache an image.
-
#canny(**opts) ⇒ Vips::Image
Canny edge detector.
-
#case(cases, **opts) ⇒ Vips::Image
Use pixel values to pick cases from an array of images.
-
#cast(format, **opts) ⇒ Vips::Image
Cast an image.
-
#ceil ⇒ Image
Return the smallest integral value not less than the argument.
-
#CMC2LCh(**opts) ⇒ Vips::Image
Transform lch to cmc.
-
#CMYK2XYZ(**opts) ⇒ Vips::Image
Transform cmyk to xyz.
-
#coding ⇒ Symbol
Get image coding.
-
#colourspace(space, **opts) ⇒ Vips::Image
Convert to a new colorspace.
-
#compass(mask, **opts) ⇒ Vips::Image
Convolve with rotating mask.
-
#complex(cmplx, **opts) ⇒ Vips::Image
Perform a complex operation on an image.
-
#complex2(right, cmplx, **opts) ⇒ Vips::Image
Complex binary operations on two images.
-
#complexform(right, **opts) ⇒ Vips::Image
Form a complex image from two real images.
-
#complexget(get, **opts) ⇒ Vips::Image
Get a component from a complex image.
-
#composite(overlay, mode, **opts) ⇒ Image
Composite a set of images with a set of blend modes.
-
#composite2(overlay, mode, **opts) ⇒ Vips::Image
Blend a pair of images with a blend mode.
-
#conj ⇒ Image
Return the complex conjugate of an image.
-
#conv(mask, **opts) ⇒ Vips::Image
Convolution operation.
-
#conva(mask, **opts) ⇒ Vips::Image
Approximate integer convolution.
-
#convasep(mask, **opts) ⇒ Vips::Image
Approximate separable integer convolution.
-
#convf(mask, **opts) ⇒ Vips::Image
Float convolution operation.
-
#convi(mask, **opts) ⇒ Vips::Image
Int convolution operation.
-
#convsep(mask, **opts) ⇒ Vips::Image
Seperable convolution operation.
-
#copy(**opts) ⇒ Vips::Image
Copy an image.
-
#copy_memory ⇒ Image
Copy an image to a memory area.
-
#cos ⇒ Image
Return the cosine of an image in degrees.
-
#countlines(direction, **opts) ⇒ Float
Count lines in an image.
-
#crop(left, top, width, height, **opts) ⇒ Vips::Image
Extract an area from an image.
-
#cross_phase(other) ⇒ Image
Calculate the cross phase of two images.
-
#csvsave(filename, **opts) ⇒ nil
Save image to csv.
-
#csvsave_target(target, **opts) ⇒ nil
Save image to csv.
-
#dE00(right, **opts) ⇒ Vips::Image
Calculate de00.
-
#dE76(right, **opts) ⇒ Vips::Image
Calculate de76.
-
#dECMC(right, **opts) ⇒ Vips::Image
Calculate decmc.
-
#deviate(**opts) ⇒ Float
Find image standard deviation.
-
#dilate(mask) ⇒ Image
Dilate with a structuring element.
-
#divide(right, **opts) ⇒ Vips::Image
Divide two images.
-
#draw_circle(ink, cx, cy, radius, **opts) ⇒ Vips::Image
Draw a circle on an image.
-
#draw_flood(ink, x, y, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Flood-fill an area.
-
#draw_image(sub, x, y, **opts) ⇒ Vips::Image
Paint an image into another image.
-
#draw_line(ink, x1, y1, x2, y2, **opts) ⇒ Vips::Image
Draw a line on an image.
-
#draw_mask(ink, mask, x, y, **opts) ⇒ Vips::Image
Draw a mask on an image.
-
#draw_point(ink, left, top, **opts) ⇒ Image
Draw a point on an image.
-
#draw_rect(ink, left, top, width, height, **opts) ⇒ Vips::Image
Paint a rectangle on an image.
-
#draw_smudge(left, top, width, height, **opts) ⇒ Vips::Image
Blur a rectangle on an image.
-
#dzsave(filename, **opts) ⇒ nil
Save image to deepzoom file.
-
#dzsave_buffer(**opts) ⇒ VipsBlob
Save image to dz buffer.
-
#embed(x, y, width, height, **opts) ⇒ Vips::Image
Embed an image in a larger image.
-
#erode(mask) ⇒ Image
Erode with a structuring element.
-
#exp ⇒ Image
Return e ** pixel.
-
#exp10 ⇒ Image
Return 10 ** pixel.
-
#extract_area(left, top, width, height, **opts) ⇒ Vips::Image
Extract an area from an image.
-
#extract_band(band, **opts) ⇒ Vips::Image
Extract band from an image.
-
#falsecolour(**opts) ⇒ Vips::Image
False-color an image.
-
#fastcor(ref, **opts) ⇒ Vips::Image
Fast correlation.
-
#filename ⇒ String
Get image filename, if any.
-
#fill_nearest(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Fill image zeros with nearest non-zero pixel.
-
#find_trim(**opts) ⇒ Array<Integer, Integer, Integer, Integer>
Search an image for non-edge areas.
-
#fitssave(filename, **opts) ⇒ nil
Save image to fits file.
-
#flatten(**opts) ⇒ Vips::Image
Flatten alpha out of an image.
-
#flip(direction, **opts) ⇒ Vips::Image
Flip an image.
-
#fliphor ⇒ Image
Flip horizontally.
-
#flipver ⇒ Image
Flip vertically.
-
#float2rad(**opts) ⇒ Vips::Image
Transform float rgb to radiance coding.
-
#floor ⇒ Image
Return the largest integral value not greater than the argument.
-
#format ⇒ Symbol
Get image format.
-
#freqmult(mask, **opts) ⇒ Vips::Image
Frequency-domain filtering.
-
#fwfft(**opts) ⇒ Vips::Image
Forward fft.
-
#gamma(**opts) ⇒ Vips::Image
Gamma an image.
-
#gaussblur(sigma, **opts) ⇒ Vips::Image
Gaussian blur.
-
#get(name) ⇒ Object
Get a metadata item from an image.
-
#get_fields ⇒ [String]
Get the names of all fields on an image.
-
#get_typeof(name) ⇒ Integer
Get the
GType
of a metadata field. -
#get_value(name) ⇒ Object
compatibility: old name for get.
-
#getpoint(x, y, **opts) ⇒ Array<Double>
Read a point from an image.
-
#globalbalance(**opts) ⇒ Vips::Image
Global balance an image mosaic.
-
#gravity(direction, width, height, **opts) ⇒ Vips::Image
Place an image within a larger image with a certain gravity.
-
#grid(tile_height, across, down, **opts) ⇒ Vips::Image
Grid an image.
-
#has_alpha? ⇒ Boolean
Detect if image has an alpha channel.
-
#heifsave(filename, **opts) ⇒ nil
Save image in heif format.
-
#heifsave_buffer(**opts) ⇒ VipsBlob
Save image in heif format.
-
#heifsave_target(target, **opts) ⇒ nil
Save image in heif format.
-
#height ⇒ Integer
Get image height, in pixels.
-
#hist_cum(**opts) ⇒ Vips::Image
Form cumulative histogram.
-
#hist_entropy(**opts) ⇒ Float
Estimate image entropy.
-
#hist_equal(**opts) ⇒ Vips::Image
Histogram equalisation.
-
#hist_find(**opts) ⇒ Vips::Image
Find image histogram.
-
#hist_find_indexed(index, **opts) ⇒ Vips::Image
Find indexed image histogram.
-
#hist_find_ndim(**opts) ⇒ Vips::Image
Find n-dimensional image histogram.
-
#hist_ismonotonic(**opts) ⇒ Boolean
Test for monotonicity.
-
#hist_local(width, height, **opts) ⇒ Vips::Image
Local histogram equalisation.
-
#hist_match(ref, **opts) ⇒ Vips::Image
Match two histograms.
-
#hist_norm(**opts) ⇒ Vips::Image
Normalise histogram.
-
#hist_plot(**opts) ⇒ Vips::Image
Plot histogram.
-
#hough_circle(**opts) ⇒ Vips::Image
Find hough circle transform.
-
#hough_line(**opts) ⇒ Vips::Image
Find hough line transform.
-
#HSV2sRGB(**opts) ⇒ Vips::Image
Transform hsv to srgb.
-
#icc_export(**opts) ⇒ Vips::Image
Output to device with icc profile.
-
#icc_import(**opts) ⇒ Vips::Image
Import from device with icc profile.
-
#icc_transform(output_profile, **opts) ⇒ Vips::Image
Transform between devices with icc profiles.
-
#ifthenelse(th, el, **opts) ⇒ Image
Select pixels from
th
ifself
is non-zero and fromel
ifself
is zero. -
#imag ⇒ Image
Return the imaginary part of a complex image.
-
#insert(sub, x, y, **opts) ⇒ Vips::Image
Insert image @sub into @main at @x, @y.
- #inspect ⇒ Object
-
#interpretation ⇒ Symbol
Get image interpretation.
-
#invert(**opts) ⇒ Vips::Image
Invert an image.
-
#invertlut(**opts) ⇒ Vips::Image
Build an inverted look-up table.
-
#invfft(**opts) ⇒ Vips::Image
Inverse fft.
-
#join(in2, direction, **opts) ⇒ Vips::Image
Join a pair of images.
-
#jp2ksave(filename, **opts) ⇒ nil
Save image in jpeg2000 format.
-
#jp2ksave_buffer(**opts) ⇒ VipsBlob
Save image in jpeg2000 format.
-
#jp2ksave_target(target, **opts) ⇒ nil
Save image in jpeg2000 format.
-
#jpegsave(filename, **opts) ⇒ nil
Save image to jpeg file.
-
#jpegsave_buffer(**opts) ⇒ VipsBlob
Save image to jpeg buffer.
-
#jpegsave_mime(**opts) ⇒ nil
Save image to jpeg mime.
-
#jpegsave_target(target, **opts) ⇒ nil
Save image to jpeg target.
-
#jxlsave(filename, **opts) ⇒ nil
Save image in jpeg-xl format.
-
#jxlsave_buffer(**opts) ⇒ VipsBlob
Save image in jpeg-xl format.
-
#jxlsave_target(target, **opts) ⇒ nil
Save image in jpeg-xl format.
-
#Lab2LabQ(**opts) ⇒ Vips::Image
Transform float lab to labq coding.
-
#Lab2LabS(**opts) ⇒ Vips::Image
Transform float lab to signed short.
-
#Lab2LCh(**opts) ⇒ Vips::Image
Transform lab to lch.
-
#Lab2XYZ(**opts) ⇒ Vips::Image
Transform cielab to xyz.
-
#labelregions(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Label regions in an image.
-
#LabQ2Lab(**opts) ⇒ Vips::Image
Unpack a labq image to float lab.
-
#LabQ2LabS(**opts) ⇒ Vips::Image
Unpack a labq image to short lab.
-
#LabQ2sRGB(**opts) ⇒ Vips::Image
Convert a labq image to srgb.
-
#LabS2Lab(**opts) ⇒ Vips::Image
Transform signed short lab to float.
-
#LabS2LabQ(**opts) ⇒ Vips::Image
Transform short lab to labq coding.
-
#LCh2CMC(**opts) ⇒ Vips::Image
Transform lch to cmc.
-
#LCh2Lab(**opts) ⇒ Vips::Image
Transform lch to lab.
-
#linear(a, b, **opts) ⇒ Vips::Image
Calculate (a * in + b).
-
#linecache(**opts) ⇒ Vips::Image
Cache an image as a set of lines.
-
#log ⇒ Image
Return the natural log of an image.
-
#log10 ⇒ Image
Return the log base 10 of an image.
-
#magicksave(filename, **opts) ⇒ nil
Save file with imagemagick.
-
#magicksave_buffer(**opts) ⇒ VipsBlob
Save image to magick buffer.
-
#mapim(index, **opts) ⇒ Vips::Image
Resample with a map image.
-
#maplut(lut, **opts) ⇒ Vips::Image
Map an image though a lut.
-
#match(sec, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, **opts) ⇒ Vips::Image
First-order match of two images.
-
#math(math, **opts) ⇒ Vips::Image
Apply a math operation to an image.
-
#math2(right, math2, **opts) ⇒ Vips::Image
Binary math operations.
-
#math2_const(math2, c, **opts) ⇒ Vips::Image
Binary math operations with a constant.
-
#matrixinvert(**opts) ⇒ Vips::Image
Invert an matrix.
-
#matrixprint(**opts) ⇒ nil
Print matrix.
-
#matrixsave(filename, **opts) ⇒ nil
Save image to matrix.
-
#matrixsave_target(target, **opts) ⇒ nil
Save image to matrix.
-
#max(**opts) ⇒ Float, Hash<Symbol => Object>
Find image maximum.
-
#maxpos ⇒ Real
Return the coordinates of the image maximum.
-
#measure(h, v, **opts) ⇒ Vips::Image
Measure a set of patches on a color chart.
-
#median(size = 3) ⇒ Image
a median filter.
-
#merge(sec, direction, dx, dy, **opts) ⇒ Vips::Image
Merge two images.
-
#method_missing(name, *args, **options) ⇒ Object
Invoke a vips operation with Operation.call, using self as the first input argument.
-
#min(**opts) ⇒ Float, Hash<Symbol => Object>
Find image minimum.
-
#minpos ⇒ Real
Return the coordinates of the image minimum.
-
#morph(mask, morph, **opts) ⇒ Vips::Image
Morphology operation.
-
#mosaic(sec, direction, xref, yref, xsec, ysec, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Mosaic two images.
-
#mosaic1(sec, direction, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, **opts) ⇒ Vips::Image
First-order mosaic of two images.
-
#msb(**opts) ⇒ Vips::Image
Pick most-significant byte from an image.
-
#multiply(right, **opts) ⇒ Vips::Image
Multiply two images.
-
#mutate {|mutable| ... } ⇒ Object
Mutate an image with a block.
-
#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.
-
#niftisave(filename, **opts) ⇒ nil
Save image to nifti file.
-
#offset ⇒ Float
Get offset metadata.
- #parent_get_typeof ⇒ Object
-
#percent(percent, **opts) ⇒ Integer
Find threshold for percent of pixels.
-
#phasecor(in2, **opts) ⇒ Vips::Image
Calculate phase correlation.
-
#pngsave(filename, **opts) ⇒ nil
Save image to png file.
-
#pngsave_buffer(**opts) ⇒ VipsBlob
Save image to png buffer.
-
#pngsave_target(target, **opts) ⇒ nil
Save image to target as png.
-
#polar ⇒ Image
Return an image with rectangular pixels converted to polar.
-
#ppmsave(filename, **opts) ⇒ nil
Save image to ppm file.
-
#ppmsave_target(target, **opts) ⇒ nil
Save to ppm.
-
#premultiply(**opts) ⇒ Vips::Image
Premultiply image alpha.
-
#profile(**opts) ⇒ Array<Vips::Image, Vips::Image>
Find image profiles.
-
#project(**opts) ⇒ Array<Vips::Image, Vips::Image>
Find image projections.
-
#quadratic(coeff, **opts) ⇒ Vips::Image
Resample an image with a quadratic transform.
-
#rad2float(**opts) ⇒ Vips::Image
Unpack radiance coding to float rgb.
-
#radsave(filename, **opts) ⇒ nil
Save image to radiance file.
-
#radsave_buffer(**opts) ⇒ VipsBlob
Save image to radiance buffer.
-
#radsave_target(target, **opts) ⇒ nil
Save image to radiance target.
-
#rank(width, height, index, **opts) ⇒ Vips::Image
Rank filter.
-
#rawsave(filename, **opts) ⇒ nil
Save image to raw file.
-
#rawsave_fd(fd, **opts) ⇒ nil
Write raw image to file descriptor.
-
#real ⇒ Image
Return the real part of a complex image.
-
#recomb(m, **opts) ⇒ Vips::Image
Linear recombination with matrix.
-
#rect ⇒ Image
Return an image with polar pixels converted to rectangular.
-
#reduce(hshrink, vshrink, **opts) ⇒ Vips::Image
Reduce an image.
-
#reduceh(hshrink, **opts) ⇒ Vips::Image
Shrink an image horizontally.
-
#reducev(vshrink, **opts) ⇒ Vips::Image
Shrink an image vertically.
-
#relational(right, relational, **opts) ⇒ Vips::Image
Relational operation on two images.
-
#relational_const(relational, c, **opts) ⇒ Vips::Image
Relational operations against a constant.
-
#remainder(right, **opts) ⇒ Vips::Image
Remainder after integer division of two images.
-
#remainder_const(c, **opts) ⇒ Vips::Image
Remainder after integer division of an image and a constant.
-
#remove(name) ⇒ Object
This method is deprecated.
-
#replicate(across, down, **opts) ⇒ Vips::Image
Replicate an image.
-
#resize(scale, **opts) ⇒ Vips::Image
Resize an image.
- #respond_to?(name, include_all = false) ⇒ Boolean
- #respond_to_missing?(name, include_all = false) ⇒ Boolean
-
#rint ⇒ Image
Return the nearest integral value.
-
#rot(angle, **opts) ⇒ Vips::Image
Rotate an image.
-
#rot180 ⇒ Image
Rotate by 180 degrees clockwise.
-
#rot270 ⇒ Image
Rotate by 270 degrees clockwise.
-
#rot45(**opts) ⇒ Vips::Image
Rotate an image.
-
#rot90 ⇒ Image
Rotate by 90 degrees clockwise.
-
#rotate(angle, **opts) ⇒ Vips::Image
Rotate an image by a number of degrees.
-
#round(round, **opts) ⇒ Vips::Image
Perform a round function on an image.
-
#scale ⇒ Float
Get scale metadata.
-
#scaleimage(**opts) ⇒ Vips::Image
Scale an image to uchar.
-
#scRGB2BW(**opts) ⇒ Vips::Image
Convert scrgb to bw.
-
#scRGB2sRGB(**opts) ⇒ Vips::Image
Convert an scrgb image to srgb.
-
#scRGB2XYZ(**opts) ⇒ Vips::Image
Transform scrgb to xyz.
-
#sequential(**opts) ⇒ Vips::Image
Check sequential access.
-
#set(name, value) ⇒ Object
This method is deprecated.
-
#set_kill(kill) ⇒ Object
Kill computation of this time.
-
#set_progress(state) ⇒ Object
Turn progress signalling on and off.
-
#set_type(gtype, name, value) ⇒ Object
This method is deprecated.
-
#set_value(name, value) ⇒ Object
This method is deprecated.
-
#sharpen(**opts) ⇒ Vips::Image
Unsharp masking for print.
-
#shrink(hshrink, vshrink, **opts) ⇒ Vips::Image
Shrink an image.
-
#shrinkh(hshrink, **opts) ⇒ Vips::Image
Shrink an image horizontally.
-
#shrinkv(vshrink, **opts) ⇒ Vips::Image
Shrink an image vertically.
-
#sign(**opts) ⇒ Vips::Image
Unit vector of pixel.
-
#similarity(**opts) ⇒ Vips::Image
Similarity transform of an image.
-
#sin ⇒ Image
Return the sine of an image in degrees.
-
#size ⇒ Integer
Get the image size.
-
#smartcrop(width, height, **opts) ⇒ Vips::Image
Extract an area from an image.
-
#sobel(**opts) ⇒ Vips::Image
Sobel edge detector.
-
#spcor(ref, **opts) ⇒ Vips::Image
Spatial correlation.
-
#spectrum(**opts) ⇒ Vips::Image
Make displayable power spectrum.
-
#sRGB2HSV(**opts) ⇒ Vips::Image
Transform srgb to hsv.
-
#sRGB2scRGB(**opts) ⇒ Vips::Image
Convert an srgb image to scrgb.
-
#stats(**opts) ⇒ Vips::Image
Find many image stats.
-
#stdif(width, height, **opts) ⇒ Vips::Image
Statistical difference.
-
#subsample(xfac, yfac, **opts) ⇒ Vips::Image
Subsample an image.
-
#subtract(right, **opts) ⇒ Vips::Image
Subtract two images.
-
#tan ⇒ Image
Return the tangent of an image in degrees.
-
#thumbnail_image(width, **opts) ⇒ Vips::Image
Generate thumbnail from image.
-
#tiffsave(filename, **opts) ⇒ nil
Save image to tiff file.
-
#tiffsave_buffer(**opts) ⇒ VipsBlob
Save image to tiff buffer.
-
#tilecache(**opts) ⇒ Vips::Image
Cache an image as a set of tiles.
-
#to_a ⇒ Array
Convert to an Array.
-
#to_enum ⇒ Enumerator
Convert to an Enumerator.
-
#transpose3d(**opts) ⇒ Vips::Image
Transpose3d an image.
-
#unpremultiply(**opts) ⇒ Vips::Image
Unpremultiply image alpha.
-
#vipssave(filename, **opts) ⇒ nil
Save image to file in vips format.
-
#vipssave_target(target, **opts) ⇒ nil
Save image to target in vips format.
-
#webpsave(filename, **opts) ⇒ nil
Save image to webp file.
-
#webpsave_buffer(**opts) ⇒ VipsBlob
Save image to webp buffer.
-
#webpsave_target(target, **opts) ⇒ nil
Save image to webp target.
-
#width ⇒ Integer
Get image width, in pixels.
-
#wrap(**opts) ⇒ Vips::Image
Wrap image origin.
-
#write_to_buffer(format_string, **opts) ⇒ String
Write this image to a memory buffer.
-
#write_to_file(name, **opts) ⇒ Object
Write this image to a file.
-
#write_to_memory ⇒ String
Write this image to a large memory buffer.
-
#write_to_target(target, format_string, **opts) ⇒ Object
Write this image to a target.
-
#xoffset ⇒ Integer
Get image xoffset.
-
#xres ⇒ Float
Get image x resolution.
-
#XYZ2CMYK(**opts) ⇒ Vips::Image
Transform xyz to cmyk.
-
#XYZ2Lab(**opts) ⇒ Vips::Image
Transform xyz to lab.
-
#XYZ2scRGB(**opts) ⇒ Vips::Image
Transform xyz to scrgb.
-
#XYZ2Yxy(**opts) ⇒ Vips::Image
Transform xyz to yxy.
-
#yoffset ⇒ Integer
Get image yoffset.
-
#yres ⇒ Float
Get image y resolution.
-
#Yxy2XYZ(**opts) ⇒ Vips::Image
Transform yxy to xyz.
-
#zoom(xfac, yfac, **opts) ⇒ Vips::Image
Zoom an image.
-
#|(other) ⇒ Image
Integer bitwise OR with an image, constant or array.
-
#~ ⇒ Image
Equivalent to image ^ -1.
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.
228 229 230 |
# File 'lib/vips/image.rb', line 228 def method_missing name, *args, ** Vips::Operation.call name.to_s, [self, *args], end |
Class Method Details
.analyzeload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load an analyze6 image.
|
# File 'lib/vips/methods.rb', line 977
|
.arrayjoin(im, **opts) ⇒ Vips::Image
Join an array of images.
|
# File 'lib/vips/methods.rb', line 365
|
.bandrank(im, **opts) ⇒ Vips::Image
Band-wise rank of a set of images.
|
# File 'lib/vips/methods.rb', line 417
|
.black(width, height, **opts) ⇒ Vips::Image
Make a black image.
|
# File 'lib/vips/methods.rb', line 575
|
.csvload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load csv.
|
# File 'lib/vips/methods.rb', line 879
|
.csvload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load csv.
|
# File 'lib/vips/methods.rb', line 895
|
.eye(width, height, **opts) ⇒ Vips::Image
Make an image showing the eye's spatial response.
|
# File 'lib/vips/methods.rb', line 639
|
.fitsload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a fits image.
|
# File 'lib/vips/methods.rb', line 1397
|
.fitsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load fits from a source.
|
# File 'lib/vips/methods.rb', line 1409
|
.fractsurf(width, height, fractal_dimension, **opts) ⇒ Vips::Image
Make a fractal surface.
|
# File 'lib/vips/methods.rb', line 846
|
.gaussmat(sigma, min_ampl, **opts) ⇒ Vips::Image
Make a gaussian image.
|
# File 'lib/vips/methods.rb', line 603
|
.gaussnoise(width, height, **opts) ⇒ Vips::Image
Make a gaussnoise image.
|
# File 'lib/vips/methods.rb', line 583
|
.gifload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif with libnsgif.
|
# File 'lib/vips/methods.rb', line 1169
|
.gifload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif with libnsgif.
|
# File 'lib/vips/methods.rb', line 1183
|
.gifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load gif from source.
|
# File 'lib/vips/methods.rb', line 1197
|
.grey(width, height, **opts) ⇒ Vips::Image
Make a grey ramp image.
|
# File 'lib/vips/methods.rb', line 648
|
.heifload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
|
# File 'lib/vips/methods.rb', line 1489
|
.heifload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
|
# File 'lib/vips/methods.rb', line 1505
|
.heifload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a heif image.
|
# File 'lib/vips/methods.rb', line 1521
|
.identity(**opts) ⇒ Vips::Image
Make a 1d image where pixel values are indexes.
|
# File 'lib/vips/methods.rb', line 838
|
.jp2kload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
|
# File 'lib/vips/methods.rb', line 1130
|
.jp2kload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
|
# File 'lib/vips/methods.rb', line 1143
|
.jp2kload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg2000 image.
|
# File 'lib/vips/methods.rb', line 1156
|
.jpegload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg from file.
|
# File 'lib/vips/methods.rb', line 1259
|
.jpegload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg from buffer.
|
# File 'lib/vips/methods.rb', line 1273
|
.jpegload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load image from jpeg source.
|
# File 'lib/vips/methods.rb', line 1287
|
.jxlload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
|
# File 'lib/vips/methods.rb', line 1094
|
.jxlload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
|
# File 'lib/vips/methods.rb', line 1106
|
.jxlload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load jpeg-xl image.
|
# File 'lib/vips/methods.rb', line 1118
|
.logmat(sigma, min_ampl, **opts) ⇒ Vips::Image
Make a laplacian of gaussian image.
|
# File 'lib/vips/methods.rb', line 613
|
.magickload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load file with imagemagick.
|
# File 'lib/vips/methods.rb', line 1588
|
.magickload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load buffer with imagemagick.
|
# File 'lib/vips/methods.rb', line 1604
|
.mask_butterworth(width, height, order, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a butterworth filter.
|
# File 'lib/vips/methods.rb', line 713
|
.mask_butterworth_band(width, height, order, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a butterworth_band filter.
|
# File 'lib/vips/methods.rb', line 742
|
.mask_butterworth_ring(width, height, order, frequency_cutoff, amplitude_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make a butterworth ring filter.
|
# File 'lib/vips/methods.rb', line 727
|
.mask_fractal(width, height, fractal_dimension, **opts) ⇒ Vips::Image
Make fractal filter.
|
# File 'lib/vips/methods.rb', line 800
|
.mask_gaussian(width, height, frequency_cutoff, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a gaussian filter.
|
# File 'lib/vips/methods.rb', line 758
|
.mask_gaussian_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, amplitude_cutoff, **opts) ⇒ Vips::Image
Make a gaussian filter.
|
# File 'lib/vips/methods.rb', line 785
|
.mask_gaussian_ring(width, height, frequency_cutoff, amplitude_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make a gaussian ring filter.
|
# File 'lib/vips/methods.rb', line 771
|
.mask_ideal(width, height, frequency_cutoff, **opts) ⇒ Vips::Image
Make an ideal filter.
|
# File 'lib/vips/methods.rb', line 674
|
.mask_ideal_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, **opts) ⇒ Vips::Image
Make an ideal band filter.
|
# File 'lib/vips/methods.rb', line 699
|
.mask_ideal_ring(width, height, frequency_cutoff, ringwidth, **opts) ⇒ Vips::Image
Make an ideal ring filter.
|
# File 'lib/vips/methods.rb', line 686
|
.matload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load mat from file.
|
# File 'lib/vips/methods.rb', line 1247
|
.matrix_from_array(width, height, array) ⇒ Object
464 465 466 467 468 469 470 |
# File 'lib/vips/image.rb', line 464 def self.matrix_from_array width, height, array ptr = FFI::MemoryPointer.new :double, array.length ptr.write_array_of_double array image = Vips.vips_image_new_matrix_from_array width, height, ptr, array.length Vips::Image.new image end |
.matrixload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load matrix.
|
# File 'lib/vips/methods.rb', line 911
|
.matrixload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load matrix.
|
# File 'lib/vips/methods.rb', line 923
|
.method_missing(name, *args, **options) ⇒ Object
Invoke a vips operation with Operation.call.
233 234 235 |
# File 'lib/vips/image.rb', line 233 def self.method_missing name, *args, ** Vips::Operation.call name.to_s, args, end |
.new_from_array(array, scale = 1, offset = 0) ⇒ Image
Create a new Image from a 1D or 2D array. A 1D array becomes an image with height 1. Use scale
and offset
to set the scale and offset fields in the header. These are useful for integer convolutions.
For example:
image = Vips::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.
498 499 500 501 502 503 504 505 506 507 508 509 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 |
# File 'lib/vips/image.rb', line 498 def self.new_from_array array, scale = 1, offset = 0 # we accept a 1D array and assume height == 1, or a 2D array # and check all lines are the same length unless array.is_a? Array raise Vips::Error, "Argument is not an array." end if array[0].is_a? Array height = array.length width = array[0].length unless array.all? { |x| x.is_a? Array } raise Vips::Error, "Not a 2D array." end unless array.all? { |x| x.length == width } raise Vips::Error, "Array not rectangular." end array = array.flatten else height = 1 width = array.length end unless array.length == width * height raise Vips::Error, "Bad array dimensions." end unless array.all? { |x| x.is_a? Numeric } raise Vips::Error, "Not all array elements are Numeric." end image = Vips::Image.matrix_from_array width, height, array raise Vips::Error if image.nil? image.mutate do |mutable| # be careful to set them as double mutable.set_type! GObject::GDOUBLE_TYPE, "scale", scale.to_f mutable.set_type! GObject::GDOUBLE_TYPE, "offset", offset.to_f end end |
.new_from_buffer(data, option_string, **opts) ⇒ Image
Create a new Vips::Image for an image encoded in a format such as JPEG in a binary string. Load options may be passed as strings or appended as a hash. For example:
image = Vips::Image.new_from_buffer memory_buffer, "shrink=2"
or alternatively:
image = Vips::Image.new_from_buffer memory_buffer, "", shrink: 2
The options available depend on the file format. Try something like:
$ vips jpegload_buffer
at the command-line to see the available options. Not all loaders support load from buffer, but at least JPEG, PNG and TIFF images will work.
Loading is fast: only enough of the image is loaded to be able to fill out the header. Pixels will only be decompressed when they are needed.
317 318 319 320 321 322 |
# File 'lib/vips/image.rb', line 317 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.
273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/vips/image.rb', line 273 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.(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.
365 366 367 368 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 |
# File 'lib/vips/image.rb', line 365 def self.new_from_memory data, width, height, bands, format # prevent data from being freed with JRuby FFI if defined?(JRUBY_VERSION) && !data.is_a?(FFI::Pointer) data = ::FFI::MemoryPointer.new(:char, data.bytesize).write_bytes data end if data.is_a?(FFI::Pointer) # A pointer needs to know about the size of the memory it points to. # If you have an address-only pointer, use the .slice method to wrap # the pointer in a size aware pointer. if data.size == UNKNOWN_POINTER_SIZE raise Vips::Error, "size of memory is unknown" end size = data.size else size = data.bytesize end format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format vi = Vips.vips_image_new_from_memory data, size, width, height, bands, format_number raise Vips::Error if vi.null? image = new(vi) # keep a secret ref to the underlying object .. this reference will be # inherited by things that in turn depend on us, so the memory we are # using will not be freed image.references << data image end |
.new_from_memory_copy(data, width, height, bands, format) ⇒ Image
Create a new Vips::Image from memory and copies the memory area. See new_from_memory for a version of this method which does not copy the memory area.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/vips/image.rb', line 407 def self.new_from_memory_copy data, width, height, bands, format format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format if data.is_a?(FFI::Pointer) if data.size == UNKNOWN_POINTER_SIZE raise Vips::Error, "size of memory is unknown" end size = data.size else size = data.bytesize end vi = Vips.vips_image_new_from_memory_copy data, size, width, height, bands, format_number raise Vips::Error if vi.null? new(vi) end |
.new_from_source(source, option_string, **opts) ⇒ Image
Create a new Vips::Image from a source. Load options may be passed as strings or appended as a hash. For example:
source = Vips::Source.new_from_file("k2.jpg")
image = Vips::Image.new_from_source source, "shrink=2"
or alternatively:
image = Vips::Image.new_from_source source, "", shrink: 2
The options available depend on the file format. Try something like:
$ vips jpegload_source
at the command-line to see the available options. Not all loaders support load from source, but at least JPEG, PNG and TIFF images will work.
Loading is fast: only enough data is read to be able to fill out the header. Pixels will only be read and decompressed when they are needed.
457 458 459 460 461 462 |
# File 'lib/vips/image.rb', line 457 def self.new_from_source source, option_string, **opts loader = Vips.vips_foreign_find_load_source source raise Vips::Error if loader.nil? Vips::Operation.call loader, [source], opts, option_string end |
.niftiload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load nifti volume.
|
# File 'lib/vips/methods.rb', line 1433
|
.niftiload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load nifti volumes.
|
# File 'lib/vips/methods.rb', line 1445
|
.openexrload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load an openexr image.
|
# File 'lib/vips/methods.rb', line 1421
|
.openslideload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load file with openslide.
|
# File 'lib/vips/methods.rb', line 1457
|
.openslideload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load source with openslide.
|
# File 'lib/vips/methods.rb', line 1473
|
.pdfload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from file.
|
# File 'lib/vips/methods.rb', line 1537
|
.pdfload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from buffer.
|
# File 'lib/vips/methods.rb', line 1554
|
.pdfload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load pdf from source.
|
# File 'lib/vips/methods.rb', line 1571
|
.perlin(width, height, **opts) ⇒ Vips::Image
Make a perlin noise image.
|
# File 'lib/vips/methods.rb', line 863
|
.pngload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from file.
|
# File 'lib/vips/methods.rb', line 1211
|
.pngload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from buffer.
|
# File 'lib/vips/methods.rb', line 1223
|
.pngload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load png from source.
|
# File 'lib/vips/methods.rb', line 1235
|
.ppmload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load ppm from file.
|
# File 'lib/vips/methods.rb', line 989
|
.ppmload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load ppm base class.
|
# File 'lib/vips/methods.rb', line 1001
|
.profile_load(name, **opts) ⇒ VipsBlob
Load named icc profile.
|
# File 'lib/vips/methods.rb', line 2594
|
.radload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load a radiance image from a file.
|
# File 'lib/vips/methods.rb', line 1013
|
.radload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load rad from buffer.
|
# File 'lib/vips/methods.rb', line 1025
|
.radload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load rad from source.
|
# File 'lib/vips/methods.rb', line 1037
|
.rawload(filename, width, height, bands, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load raw data from a file.
|
# File 'lib/vips/methods.rb', line 935
|
.respond_to_missing?(name, include_all = false) ⇒ Boolean
216 217 218 219 220 221 |
# File 'lib/vips/image.rb', line 216 def self.respond_to_missing? name, include_all = false # respond to all vips operations by nickname return true if Vips.type_find("VipsOperation", name.to_s) != 0 super end |
.sines(width, height, **opts) ⇒ Vips::Image
Make a 2d sine wave.
|
# File 'lib/vips/methods.rb', line 664
|
.svgload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg with rsvg.
|
# File 'lib/vips/methods.rb', line 1049
|
.svgload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg with rsvg.
|
# File 'lib/vips/methods.rb', line 1064
|
.svgload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load svg from source.
|
# File 'lib/vips/methods.rb', line 1079
|
.switch(tests, **opts) ⇒ Vips::Image
Find the index of the first non-zero pixel in tests.
|
# File 'lib/vips/methods.rb', line 873
|
.system(cmd_format, **opts) ⇒ nil, Hash<Symbol => Object>
Run an external command.
|
# File 'lib/vips/methods.rb', line 4
|
.text(text, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Make a text image.
|
# File 'lib/vips/methods.rb', line 623
|
.thumbnail(filename, width, **opts) ⇒ Vips::Image
Generate thumbnail from file.
|
# File 'lib/vips/methods.rb', line 2220
|
.thumbnail_buffer(buffer, width, **opts) ⇒ Vips::Image
Generate thumbnail from buffer.
|
# File 'lib/vips/methods.rb', line 2236
|
.thumbnail_source(source, width, **opts) ⇒ Vips::Image
Generate thumbnail from source.
|
# File 'lib/vips/methods.rb', line 2268
|
.tiffload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from file.
|
# File 'lib/vips/methods.rb', line 1349
|
.tiffload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from buffer.
|
# File 'lib/vips/methods.rb', line 1365
|
.tiffload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load tiff from source.
|
# File 'lib/vips/methods.rb', line 1381
|
.vipsload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load vips from file.
|
# File 'lib/vips/methods.rb', line 953
|
.vipsload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load vips from source.
|
# File 'lib/vips/methods.rb', line 965
|
.webpload(filename, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from file.
|
# File 'lib/vips/methods.rb', line 1301
|
.webpload_buffer(buffer, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from buffer.
|
# File 'lib/vips/methods.rb', line 1317
|
.webpload_source(source, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Load webp from source.
|
# File 'lib/vips/methods.rb', line 1333
|
.worley(width, height, **opts) ⇒ Vips::Image
Make a worley noise image.
|
# File 'lib/vips/methods.rb', line 854
|
.xyz(width, height, **opts) ⇒ Vips::Image
Make an image where pixel values are coordinates.
|
# File 'lib/vips/methods.rb', line 593
|
.zone(width, height, **opts) ⇒ Vips::Image
Make a zone plate.
|
# File 'lib/vips/methods.rb', line 656
|
Instance Method Details
#! ⇒ Image
Equivalent to image ^ -1
1077 1078 1079 |
# File 'lib/vips/image.rb', line 1077 def ! self ^ -1 end |
#!=(other) ⇒ Image
Compare inequality to nil, an image, constant or array.
1151 1152 1153 1154 1155 1156 1157 1158 |
# File 'lib/vips/image.rb', line 1151 def != other # for equality, we must allow tests against nil if other.nil? true else call_enum "relational", other, :noteq end end |
#%(other) ⇒ Image
Remainder after integer division with an image, constant or array.
1021 1022 1023 1024 |
# File 'lib/vips/image.rb', line 1021 def % other other.is_a?(Vips::Image) ? remainder(other) : remainder_const(other) end |
#&(other) ⇒ Image
Integer bitwise AND with an image, constant or array.
1062 1063 1064 |
# File 'lib/vips/image.rb', line 1062 def & other call_enum "boolean", other, :and end |
#*(other) ⇒ Image
Multiply an image, constant or array.
1003 1004 1005 1006 |
# File 'lib/vips/image.rb', line 1003 def * other other.is_a?(Vips::Image) ? multiply(other) : linear(other, 0) end |
#**(other) ⇒ Image
Raise to power of an image, constant or array.
1030 1031 1032 |
# File 'lib/vips/image.rb', line 1030 def ** other call_enum "math2", other, :pow end |
#+(other) ⇒ Image
Add an image, constant or array.
985 986 987 988 |
# File 'lib/vips/image.rb', line 985 def + other other.is_a?(Vips::Image) ? add(other) : linear(1, other) end |
#-(other) ⇒ Image
Subtract an image, constant or array.
994 995 996 997 |
# File 'lib/vips/image.rb', line 994 def - other other.is_a?(Vips::Image) ? subtract(other) : linear(1, Image.smap(other) { |x| x * -1 }) end |
#-@ ⇒ Image
Equivalent to image * -1
1096 1097 1098 |
# File 'lib/vips/image.rb', line 1096 def -@ self * -1 end |
#/(other) ⇒ Image
Divide an image, constant or array.
1012 1013 1014 1015 |
# File 'lib/vips/image.rb', line 1012 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.
1104 1105 1106 |
# File 'lib/vips/image.rb', line 1104 def < other call_enum "relational", other, :less end |
#<<(other) ⇒ Image
Integer left shift with an image, constant or array.
1038 1039 1040 |
# File 'lib/vips/image.rb', line 1038 def << other call_enum "boolean", other, :lshift end |
#<=(other) ⇒ Image
Relational less than or equal to with an image, constant or array.
1113 1114 1115 |
# File 'lib/vips/image.rb', line 1113 def <= other call_enum "relational", other, :lesseq end |
#==(other) ⇒ Image
Compare equality to nil, an image, constant or array.
1138 1139 1140 1141 1142 1143 1144 1145 |
# File 'lib/vips/image.rb', line 1138 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.
1121 1122 1123 |
# File 'lib/vips/image.rb', line 1121 def > other call_enum "relational", other, :more end |
#>=(other) ⇒ Image
Relational more than or equal to with an image, constant or array.
1130 1131 1132 |
# File 'lib/vips/image.rb', line 1130 def >= other call_enum "relational", other, :moreeq end |
#>>(other) ⇒ Image
Integer right shift with an image, constant or array.
1046 1047 1048 |
# File 'lib/vips/image.rb', line 1046 def >> other call_enum "boolean", other, :rshift end |
#[](index) ⇒ Image
Fetch bands using a number or a range
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
# File 'lib/vips/image.rb', line 1164 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.
1070 1071 1072 |
# File 'lib/vips/image.rb', line 1070 def ^ other call_enum "boolean", other, :eor end |
#acos ⇒ Image
Return the inverse cosine of an image in degrees.
1426 1427 1428 |
# File 'lib/vips/image.rb', line 1426 def acos math :acos end |
#add_alpha ⇒ Image
Append an alpha channel to an image.
951 952 953 954 955 956 957 |
# File 'lib/vips/image.rb', line 951 def add_alpha ptr = GenericPtr.new result = Vips.vips_addalpha self, ptr raise Vips::Error if result != 0 Vips::Image.new ptr[:value] end |
#affine(matrix, **opts) ⇒ Vips::Image
Affine transform of an image.
|
# File 'lib/vips/methods.rb', line 2351
|
#asin ⇒ Image
Return the inverse sine of an image in degrees.
1419 1420 1421 |
# File 'lib/vips/image.rb', line 1419 def asin math :asin end |
#atan ⇒ Image
Return the inverse tangent of an image in degrees.
1433 1434 1435 |
# File 'lib/vips/image.rb', line 1433 def atan math :atan end |
#autorot(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Autorotate image by exif tag.
|
# File 'lib/vips/methods.rb', line 461
|
#avg(**opts) ⇒ Float
Find image average.
|
# File 'lib/vips/methods.rb', line 159
|
#bandand ⇒ Image
AND the bands of an image together
1235 1236 1237 |
# File 'lib/vips/image.rb', line 1235 def bandand bandbool :and end |
#bandbool(boolean, **opts) ⇒ Vips::Image
Boolean operation across image bands.
|
# File 'lib/vips/methods.rb', line 429
|
#bandeor ⇒ Image
EOR the bands of an image together
1249 1250 1251 |
# File 'lib/vips/image.rb', line 1249 def bandeor bandbool :eor end |
#bandjoin(other) ⇒ Image
Join a set of images bandwise.
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 |
# File 'lib/vips/image.rb', line 1264 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 411
|
#bandor ⇒ Image
OR the bands of an image together
1242 1243 1244 |
# File 'lib/vips/image.rb', line 1242 def bandor bandbool :or end |
#bands ⇒ Integer
Get number of image bands.
852 853 854 |
# File 'lib/vips/image.rb', line 852 def bands Vips.vips_image_get_bands self end |
#bandsplit ⇒ Array<Image>
Split an n-band image into n separate images.
1256 1257 1258 |
# File 'lib/vips/image.rb', line 1256 def bandsplit (0...bands).map { |i| extract_band i } end |
#bandunfold(**opts) ⇒ Vips::Image
Unfold image bands into x axis.
|
# File 'lib/vips/methods.rb', line 480
|
#boolean(right, boolean, **opts) ⇒ Vips::Image
Boolean operation on two images.
|
# File 'lib/vips/methods.rb', line 52
|
#boolean_const(boolean, c, **opts) ⇒ Vips::Image
Boolean operations against a constant.
|
# File 'lib/vips/methods.rb', line 133
|
#case(cases, **opts) ⇒ Vips::Image
Use pixel values to pick cases from an array of images.
|
# File 'lib/vips/methods.rb', line 2607
|
#ceil ⇒ Image
Return the smallest integral value not less than the argument.
1221 1222 1223 |
# File 'lib/vips/image.rb', line 1221 def ceil round :ceil end |
#coding ⇒ Symbol
Get image coding.
873 874 875 |
# File 'lib/vips/image.rb', line 873 def coding get "coding" end |
#colourspace(space, **opts) ⇒ Vips::Image
Convert to a new colorspace.
|
# File 'lib/vips/methods.rb', line 2403
|
#compass(mask, **opts) ⇒ Vips::Image
Convolve with rotating mask.
|
# File 'lib/vips/methods.rb', line 2704
|
#complex(cmplx, **opts) ⇒ Vips::Image
Perform a complex operation on an image.
|
# File 'lib/vips/methods.rb', line 147
|
#complex2(right, cmplx, **opts) ⇒ Vips::Image
Complex binary operations on two images.
|
# File 'lib/vips/methods.rb', line 66
|
#complexform(right, **opts) ⇒ Vips::Image
Form a complex image from two real images.
|
# File 'lib/vips/methods.rb', line 73
|
#complexget(get, **opts) ⇒ Vips::Image
Get a component from a complex image.
|
# File 'lib/vips/methods.rb', line 153
|
#composite(overlay, mode, **opts) ⇒ Image
Composite a set of images with a set of blend modes.
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 |
# File 'lib/vips/image.rb', line 1290 def composite , mode, **opts unless .is_a? Array = [] end unless mode.is_a? Array mode = [mode] end mode = mode.map do |x| GObject::GValue.from_nick Vips::BLEND_MODE_TYPE, x end Vips::Image.composite([self] + , mode, **opts) end |
#composite2(overlay, mode, **opts) ⇒ Vips::Image
Blend a pair of images with a blend mode.
|
# File 'lib/vips/methods.rb', line 564
|
#conj ⇒ Image
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.
1383 1384 1385 |
# File 'lib/vips/image.rb', line 1383 def conj Image.run_cmplx(self) { |x| x.complex :conj } end |
#conva(mask, **opts) ⇒ Vips::Image
Approximate integer convolution.
|
# File 'lib/vips/methods.rb', line 2684
|
#convasep(mask, **opts) ⇒ Vips::Image
Approximate separable integer convolution.
|
# File 'lib/vips/methods.rb', line 2725
|
#convf(mask, **opts) ⇒ Vips::Image
Float convolution operation.
|
# File 'lib/vips/methods.rb', line 2692
|
#convi(mask, **opts) ⇒ Vips::Image
Int convolution operation.
|
# File 'lib/vips/methods.rb', line 2698
|
#convsep(mask, **opts) ⇒ Vips::Image
Seperable convolution operation.
|
# File 'lib/vips/methods.rb', line 2716
|
#copy_memory ⇒ Image
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.
967 968 969 970 |
# File 'lib/vips/image.rb', line 967 def copy_memory new_image = Vips.vips_image_copy_memory self Vips::Image.new new_image end |
#cos ⇒ Image
Return the cosine of an image in degrees.
1405 1406 1407 |
# File 'lib/vips/image.rb', line 1405 def cos math :cos end |
#countlines(direction, **opts) ⇒ Float
Count lines in an image.
|
# File 'lib/vips/methods.rb', line 2819
|
#crop(left, top, width, height, **opts) ⇒ Vips::Image
Extract an area from an image.
|
# File 'lib/vips/methods.rb', line 387
|
#cross_phase(other) ⇒ Image
Calculate the cross phase of two images.
1391 1392 1393 |
# File 'lib/vips/image.rb', line 1391 def cross_phase other complex2 other, :cross_phase end |
#csvsave(filename, **opts) ⇒ nil
Save image to csv.
|
# File 'lib/vips/methods.rb', line 1620
|
#csvsave_target(target, **opts) ⇒ nil
Save image to csv.
|
# File 'lib/vips/methods.rb', line 1630
|
#deviate(**opts) ⇒ Float
Find image standard deviation.
|
# File 'lib/vips/methods.rb', line 186
|
#dilate(mask) ⇒ Image
Dilate with a structuring element.
The structuring element must be an array with 0 for black, 255 for white and 128 for don't care.
1499 1500 1501 |
# File 'lib/vips/image.rb', line 1499 def dilate mask morph mask, :dilate end |
#draw_circle(ink, cx, cy, radius, **opts) ⇒ Vips::Image
Draw a circle on an image.
|
# File 'lib/vips/methods.rb', line 2867
|
#draw_flood(ink, x, y, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Flood-fill an area.
|
# File 'lib/vips/methods.rb', line 2877
|
#draw_image(sub, x, y, **opts) ⇒ Vips::Image
Paint an image into another image.
|
# File 'lib/vips/methods.rb', line 2891
|
#draw_line(ink, x1, y1, x2, y2, **opts) ⇒ Vips::Image
Draw a line on an image.
|
# File 'lib/vips/methods.rb', line 2857
|
#draw_mask(ink, mask, x, y, **opts) ⇒ Vips::Image
Draw a mask on an image.
|
# File 'lib/vips/methods.rb', line 2848
|
#draw_point(ink, left, top, **opts) ⇒ Image
Draw a point on an image.
See #draw_rect.
977 978 979 |
# File 'lib/vips/image.rb', line 977 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.
|
# File 'lib/vips/methods.rb', line 2837
|
#draw_smudge(left, top, width, height, **opts) ⇒ Vips::Image
Blur a rectangle on an image.
|
# File 'lib/vips/methods.rb', line 2900
|
#dzsave(filename, **opts) ⇒ nil
Save image to deepzoom file.
|
# File 'lib/vips/methods.rb', line 1834
|
#dzsave_buffer(**opts) ⇒ VipsBlob
Save image to dz buffer.
|
# File 'lib/vips/methods.rb', line 1861
|
#embed(x, y, width, height, **opts) ⇒ Vips::Image
Embed an image in a larger image.
|
# File 'lib/vips/methods.rb', line 317
|
#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.
1487 1488 1489 |
# File 'lib/vips/image.rb', line 1487 def erode mask morph mask, :erode end |
#exp ⇒ Image
Return e ** pixel.
1454 1455 1456 |
# File 'lib/vips/image.rb', line 1454 def exp math :exp end |
#exp10 ⇒ Image
Return 10 ** pixel.
1461 1462 1463 |
# File 'lib/vips/image.rb', line 1461 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 378
|
#extract_band(band, **opts) ⇒ Vips::Image
Extract band from an image.
|
# File 'lib/vips/methods.rb', line 404
|
#filename ⇒ String
Get image filename, if any.
880 881 882 |
# File 'lib/vips/image.rb', line 880 def filename get "filename" end |
#fill_nearest(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Fill image zeros with nearest non-zero pixel.
|
# File 'lib/vips/methods.rb', line 2831
|
#find_trim(**opts) ⇒ Array<Integer, Integer, Integer, Integer>
Search an image for non-edge areas.
|
# File 'lib/vips/methods.rb', line 258
|
#fitssave(filename, **opts) ⇒ nil
Save image to fits file.
|
# File 'lib/vips/methods.rb', line 2136
|
#flatten(**opts) ⇒ Vips::Image
Flatten alpha out of an image.
|
# File 'lib/vips/methods.rb', line 486
|
#fliphor ⇒ Image
Flip horizontally.
1468 1469 1470 |
# File 'lib/vips/image.rb', line 1468 def fliphor flip :horizontal end |
#flipver ⇒ Image
Flip vertically.
1475 1476 1477 |
# File 'lib/vips/image.rb', line 1475 def flipver flip :vertical end |
#float2rad(**opts) ⇒ Vips::Image
Transform float rgb to radiance coding.
|
# File 'lib/vips/methods.rb', line 2497
|
#floor ⇒ Image
Return the largest integral value not greater than the argument.
1214 1215 1216 |
# File 'lib/vips/image.rb', line 1214 def floor round :floor end |
#format ⇒ Symbol
Get image format.
859 860 861 |
# File 'lib/vips/image.rb', line 859 def format get "format" end |
#freqmult(mask, **opts) ⇒ Vips::Image
Frequency-domain filtering.
|
# File 'lib/vips/methods.rb', line 2787
|
#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.
740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'lib/vips/image.rb', line 740 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.
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'lib/vips/image.rb', line 759 def get_fields # vips_image_get_fields() was added in libvips 8.5 return [] unless Vips.respond_to? :vips_image_get_fields array = Vips.vips_image_get_fields self names = [] p = array until (q = p.read_pointer).null? names << q.read_string GLib.g_free q p += FFI::Type::POINTER.size end GLib.g_free array names end |
#get_typeof(name) ⇒ Integer
Get the GType
of a metadata field. The result is 0 if no such field exists.
716 717 718 719 720 721 722 723 724 725 |
# File 'lib/vips/image.rb', line 716 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
824 825 826 |
# File 'lib/vips/image.rb', line 824 def get_value name get name end |
#getpoint(x, y, **opts) ⇒ Array<Double>
Read a point from an image.
|
# File 'lib/vips/methods.rb', line 251
|
#globalbalance(**opts) ⇒ Vips::Image
Global balance an image mosaic.
|
# File 'lib/vips/methods.rb', line 2984
|
#gravity(direction, width, height, **opts) ⇒ Vips::Image
Place an image within a larger image with a certain gravity.
|
# File 'lib/vips/methods.rb', line 328
|
#grid(tile_height, across, down, **opts) ⇒ Vips::Image
Grid an image.
|
# File 'lib/vips/methods.rb', line 506
|
#has_alpha? ⇒ Boolean
Detect if image has an alpha channel
941 942 943 |
# File 'lib/vips/image.rb', line 941 def has_alpha? Vips.vips_image_hasalpha(self) != 0 end |
#heifsave(filename, **opts) ⇒ nil
Save image in heif format.
|
# File 'lib/vips/methods.rb', line 2154
|
#heifsave_buffer(**opts) ⇒ VipsBlob
Save image in heif format.
|
# File 'lib/vips/methods.rb', line 2168
|
#heifsave_target(target, **opts) ⇒ nil
Save image in heif format.
|
# File 'lib/vips/methods.rb', line 2181
|
#height ⇒ Integer
Get image height, in pixels.
845 846 847 |
# File 'lib/vips/image.rb', line 845 def height Vips.vips_image_get_height self end |
#hist_entropy(**opts) ⇒ Float
Estimate image entropy.
|
# File 'lib/vips/methods.rb', line 2670
|
#hist_find_indexed(index, **opts) ⇒ Vips::Image
Find indexed image histogram.
|
# File 'lib/vips/methods.rb', line 208
|
#hist_find_ndim(**opts) ⇒ Vips::Image
Find n-dimensional image histogram.
|
# File 'lib/vips/methods.rb', line 202
|
#hist_ismonotonic(**opts) ⇒ Boolean
Test for monotonicity.
|
# File 'lib/vips/methods.rb', line 2665
|
#hist_local(width, height, **opts) ⇒ Vips::Image
Local histogram equalisation.
|
# File 'lib/vips/methods.rb', line 2657
|
#hist_match(ref, **opts) ⇒ Vips::Image
Match two histograms.
|
# File 'lib/vips/methods.rb', line 2635
|
#hough_circle(**opts) ⇒ Vips::Image
Find hough circle transform.
|
# File 'lib/vips/methods.rb', line 222
|
#icc_export(**opts) ⇒ Vips::Image
Output to device with icc profile.
|
# File 'lib/vips/methods.rb', line 2527
|
#icc_import(**opts) ⇒ Vips::Image
Import from device with icc profile.
|
# File 'lib/vips/methods.rb', line 2517
|
#icc_transform(output_profile, **opts) ⇒ Vips::Image
Transform between devices with icc profiles.
|
# File 'lib/vips/methods.rb', line 2537
|
#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
.
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 |
# File 'lib/vips/image.rb', line 1533 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 |
#imag ⇒ Image
Return the imaginary part of a complex image.
1345 1346 1347 |
# File 'lib/vips/image.rb', line 1345 def imag complexget :imag end |
#insert(sub, x, y, **opts) ⇒ Vips::Image
Insert image @sub into @main at @x, @y.
|
# File 'lib/vips/methods.rb', line 344
|
#inspect ⇒ Object
194 195 196 |
# File 'lib/vips/image.rb', line 194 def inspect "#<Image #{width}x#{height} #{format}, #{bands} bands, #{interpretation}>" end |
#interpretation ⇒ Symbol
Get image interpretation.
866 867 868 |
# File 'lib/vips/image.rb', line 866 def interpretation get "interpretation" end |
#invertlut(**opts) ⇒ Vips::Image
Build an inverted look-up table.
|
# File 'lib/vips/methods.rb', line 817
|
#join(in2, direction, **opts) ⇒ Vips::Image
Join a pair of images.
|
# File 'lib/vips/methods.rb', line 354
|
#jp2ksave(filename, **opts) ⇒ nil
Save image in jpeg2000 format.
|
# File 'lib/vips/methods.rb', line 1793
|
#jp2ksave_buffer(**opts) ⇒ VipsBlob
Save image in jpeg2000 format.
|
# File 'lib/vips/methods.rb', line 1807
|
#jp2ksave_target(target, **opts) ⇒ nil
Save image in jpeg2000 format.
|
# File 'lib/vips/methods.rb', line 1820
|
#jpegsave(filename, **opts) ⇒ nil
Save image to jpeg file.
|
# File 'lib/vips/methods.rb', line 1940
|
#jpegsave_buffer(**opts) ⇒ VipsBlob
Save image to jpeg buffer.
|
# File 'lib/vips/methods.rb', line 1959
|
#jpegsave_mime(**opts) ⇒ nil
Save image to jpeg mime.
|
# File 'lib/vips/methods.rb', line 1996
|
#jpegsave_target(target, **opts) ⇒ nil
Save image to jpeg target.
|
# File 'lib/vips/methods.rb', line 1977
|
#jxlsave(filename, **opts) ⇒ nil
Save image in jpeg-xl format.
|
# File 'lib/vips/methods.rb', line 1752
|
#jxlsave_buffer(**opts) ⇒ VipsBlob
Save image in jpeg-xl format.
|
# File 'lib/vips/methods.rb', line 1766
|
#jxlsave_target(target, **opts) ⇒ nil
Save image in jpeg-xl format.
|
# File 'lib/vips/methods.rb', line 1779
|
#Lab2LabQ(**opts) ⇒ Vips::Image
Transform float lab to labq coding.
|
# File 'lib/vips/methods.rb', line 2467
|
#Lab2LabS(**opts) ⇒ Vips::Image
Transform float lab to signed short.
|
# File 'lib/vips/methods.rb', line 2487
|
#labelregions(**opts) ⇒ Vips::Image, Hash<Symbol => Object>
Label regions in an image.
|
# File 'lib/vips/methods.rb', line 2825
|
#LabQ2Lab(**opts) ⇒ Vips::Image
Unpack a labq image to float lab.
|
# File 'lib/vips/methods.rb', line 2462
|
#LabQ2LabS(**opts) ⇒ Vips::Image
Unpack a labq image to short lab.
|
# File 'lib/vips/methods.rb', line 2472
|
#LabQ2sRGB(**opts) ⇒ Vips::Image
Convert a labq image to srgb.
|
# File 'lib/vips/methods.rb', line 2502
|
#LabS2Lab(**opts) ⇒ Vips::Image
Transform signed short lab to float.
|
# File 'lib/vips/methods.rb', line 2482
|
#LabS2LabQ(**opts) ⇒ Vips::Image
Transform short lab to labq coding.
|
# File 'lib/vips/methods.rb', line 2477
|
#linecache(**opts) ⇒ Vips::Image
Cache an image as a set of lines.
|
# File 'lib/vips/methods.rb', line 292
|
#log ⇒ Image
Return the natural log of an image.
1440 1441 1442 |
# File 'lib/vips/image.rb', line 1440 def log math :log end |
#log10 ⇒ Image
Return the log base 10 of an image.
1447 1448 1449 |
# File 'lib/vips/image.rb', line 1447 def log10 math :log10 end |
#magicksave(filename, **opts) ⇒ nil
Save file with imagemagick.
|
# File 'lib/vips/methods.rb', line 2195
|
#magicksave_buffer(**opts) ⇒ VipsBlob
Save image to magick buffer.
|
# File 'lib/vips/methods.rb', line 2208
|
#mapim(index, **opts) ⇒ Vips::Image
Resample with a map image.
|
# File 'lib/vips/methods.rb', line 2285
|
#maplut(lut, **opts) ⇒ Vips::Image
Map an image though a lut.
|
# File 'lib/vips/methods.rb', line 2600
|
#match(sec, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, **opts) ⇒ Vips::Image
First-order match of two images.
|
# File 'lib/vips/methods.rb', line 2966
|
#math(math, **opts) ⇒ Vips::Image
Apply a math operation to an image.
|
# File 'lib/vips/methods.rb', line 98
|
#math2(right, math2, **opts) ⇒ Vips::Image
Binary math operations.
|
# File 'lib/vips/methods.rb', line 59
|
#math2_const(math2, c, **opts) ⇒ Vips::Image
Binary math operations with a constant.
|
# File 'lib/vips/methods.rb', line 140
|
#matrixprint(**opts) ⇒ nil
Print matrix.
|
# File 'lib/vips/methods.rb', line 1658
|
#matrixsave(filename, **opts) ⇒ nil
Save image to matrix.
|
# File 'lib/vips/methods.rb', line 1640
|
#matrixsave_target(target, **opts) ⇒ nil
Save image to matrix.
|
# File 'lib/vips/methods.rb', line 1649
|
#max(**opts) ⇒ Float, Hash<Symbol => Object>
Find image maximum.
|
# File 'lib/vips/methods.rb', line 175
|
#maxpos ⇒ Real
Return the coordinates of the image maximum.
1309 1310 1311 1312 1313 1314 |
# File 'lib/vips/image.rb', line 1309 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.
|
# File 'lib/vips/methods.rb', line 240
|
#median(size = 3) ⇒ Image
a median filter
1331 1332 1333 |
# File 'lib/vips/image.rb', line 1331 def median size = 3 rank size, size, size**2 / 2 end |
#merge(sec, direction, dx, dy, **opts) ⇒ Vips::Image
Merge two images.
|
# File 'lib/vips/methods.rb', line 2909
|
#min(**opts) ⇒ Float, Hash<Symbol => Object>
Find image minimum.
|
# File 'lib/vips/methods.rb', line 164
|
#minpos ⇒ Real
Return the coordinates of the image minimum.
1320 1321 1322 1323 1324 1325 |
# File 'lib/vips/image.rb', line 1320 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 2804
|
#mosaic(sec, direction, xref, yref, xsec, ysec, **opts) ⇒ Vips::Image, Hash<Symbol => Object>
Mosaic two images.
|
# File 'lib/vips/methods.rb', line 2919
|
#mosaic1(sec, direction, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2, **opts) ⇒ Vips::Image
First-order mosaic of two images.
|
# File 'lib/vips/methods.rb', line 2940
|
#msb(**opts) ⇒ Vips::Image
Pick most-significant byte from an image.
|
# File 'lib/vips/methods.rb', line 542
|
#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.
792 793 794 795 796 |
# File 'lib/vips/image.rb', line 792 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.
548 549 550 551 552 553 |
# File 'lib/vips/image.rb', line 548 def new_from_image value pixel = (Vips::Image.black(1, 1) + value).cast(format) image = pixel. 0, 0, width, height, extend: :copy image.copy interpretation: interpretation, xres: xres, yres: yres, xoffset: xoffset, yoffset: yoffset end |
#niftisave(filename, **opts) ⇒ nil
Save image to nifti file.
|
# File 'lib/vips/methods.rb', line 2145
|
#offset ⇒ Float
Get offset metadata.
924 925 926 927 928 |
# File 'lib/vips/image.rb', line 924 def offset return 0 if get_typeof("offset") == 0 get "offset" end |
#parent_get_typeof ⇒ Object
79 |
# File 'lib/vips/image.rb', line 79 alias_method :parent_get_typeof, :get_typeof |
#percent(percent, **opts) ⇒ Integer
Find threshold for percent of pixels.
|
# File 'lib/vips/methods.rb', line 2613
|
#phasecor(in2, **opts) ⇒ Vips::Image
Calculate phase correlation.
|
# File 'lib/vips/methods.rb', line 2798
|
#pngsave(filename, **opts) ⇒ nil
Save image to png file.
|
# File 'lib/vips/methods.rb', line 1887
|
#pngsave_buffer(**opts) ⇒ VipsBlob
Save image to png buffer.
|
# File 'lib/vips/methods.rb', line 1905
|
#pngsave_target(target, **opts) ⇒ nil
Save image to target as png.
|
# File 'lib/vips/methods.rb', line 1922
|
#polar ⇒ Image
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.
1358 1359 1360 |
# File 'lib/vips/image.rb', line 1358 def polar Image.run_cmplx(self) { |x| x.complex :polar } end |
#ppmsave(filename, **opts) ⇒ nil
Save image to ppm file.
|
# File 'lib/vips/methods.rb', line 1702
|
#ppmsave_target(target, **opts) ⇒ nil
Save to ppm.
|
# File 'lib/vips/methods.rb', line 1714
|
#profile(**opts) ⇒ Array<Vips::Image, Vips::Image>
Find image profiles.
|
# File 'lib/vips/methods.rb', line 235
|
#project(**opts) ⇒ Array<Vips::Image, Vips::Image>
Find image projections.
|
# File 'lib/vips/methods.rb', line 230
|
#quadratic(coeff, **opts) ⇒ Vips::Image
Resample an image with a quadratic transform.
|
# File 'lib/vips/methods.rb', line 2344
|
#rad2float(**opts) ⇒ Vips::Image
Unpack radiance coding to float rgb.
|
# File 'lib/vips/methods.rb', line 2492
|
#radsave(filename, **opts) ⇒ nil
Save image to radiance file.
|
# File 'lib/vips/methods.rb', line 1726
|
#radsave_buffer(**opts) ⇒ VipsBlob
Save image to radiance buffer.
|
# File 'lib/vips/methods.rb', line 1735
|
#radsave_target(target, **opts) ⇒ nil
Save image to radiance target.
|
# File 'lib/vips/methods.rb', line 1743
|
#rank(width, height, index, **opts) ⇒ Vips::Image
Rank filter.
|
# File 'lib/vips/methods.rb', line 2811
|
#rawsave(filename, **opts) ⇒ nil
Save image to raw file.
|
# File 'lib/vips/methods.rb', line 1666
|
#rawsave_fd(fd, **opts) ⇒ nil
Write raw image to file descriptor.
|
# File 'lib/vips/methods.rb', line 1675
|
#real ⇒ Image
Return the real part of a complex image.
1338 1339 1340 |
# File 'lib/vips/image.rb', line 1338 def real complexget :real end |
#recomb(m, **opts) ⇒ Vips::Image
Linear recombination with matrix.
|
# File 'lib/vips/methods.rb', line 468
|
#rect ⇒ Image
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.
1371 1372 1373 |
# File 'lib/vips/image.rb', line 1371 def rect Image.run_cmplx(self) { |x| x.complex :rect } end |
#reduce(hshrink, vshrink, **opts) ⇒ Vips::Image
Reduce an image.
|
# File 'lib/vips/methods.rb', line 2333
|
#reduceh(hshrink, **opts) ⇒ Vips::Image
Shrink an image horizontally.
|
# File 'lib/vips/methods.rb', line 2315
|
#reducev(vshrink, **opts) ⇒ Vips::Image
Shrink an image vertically.
|
# File 'lib/vips/methods.rb', line 2324
|
#relational(right, relational, **opts) ⇒ Vips::Image
Relational operation on two images.
|
# File 'lib/vips/methods.rb', line 39
|
#relational_const(relational, c, **opts) ⇒ Vips::Image
Relational operations against a constant.
|
# File 'lib/vips/methods.rb', line 120
|
#remainder(right, **opts) ⇒ Vips::Image
Remainder after integer division of two images.
|
# File 'lib/vips/methods.rb', line 46
|
#remainder_const(c, **opts) ⇒ Vips::Image
Remainder after integer division of an image and a constant.
|
# File 'lib/vips/methods.rb', line 127
|
#remove(name) ⇒ Object
This method is deprecated.
Please use MutableImage#remove! instead.
819 820 821 |
# File 'lib/vips/image.rb', line 819 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 435
|
#respond_to?(name, include_all = false) ⇒ Boolean
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/vips/image.rb', line 198 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
209 210 211 212 213 214 |
# File 'lib/vips/image.rb', line 209 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 |
#rint ⇒ Image
Return the nearest integral value.
1228 1229 1230 |
# File 'lib/vips/image.rb', line 1228 def rint round :rint end |
#rot180 ⇒ Image
Rotate by 180 degrees clockwise.
1513 1514 1515 |
# File 'lib/vips/image.rb', line 1513 def rot180 rot :d180 end |
#rot270 ⇒ Image
Rotate by 270 degrees clockwise.
1520 1521 1522 |
# File 'lib/vips/image.rb', line 1520 def rot270 rot :d270 end |
#rot90 ⇒ Image
Rotate by 90 degrees clockwise.
1506 1507 1508 |
# File 'lib/vips/image.rb', line 1506 def rot90 rot :d90 end |
#rotate(angle, **opts) ⇒ Vips::Image
Rotate an image by a number of degrees.
|
# File 'lib/vips/methods.rb', line 2379
|
#round(round, **opts) ⇒ Vips::Image
Perform a round function on an image.
|
# File 'lib/vips/methods.rb', line 114
|
#scale ⇒ Float
Get scale metadata.
915 916 917 918 919 |
# File 'lib/vips/image.rb', line 915 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.
1551 1552 1553 |
# File 'lib/vips/image.rb', line 1551 def scaleimage **opts Vips::Image.scale self, **opts end |
#scRGB2sRGB(**opts) ⇒ Vips::Image
Convert an scrgb image to srgb.
|
# File 'lib/vips/methods.rb', line 2578
|
#set(name, value) ⇒ Object
This method is deprecated.
Please use MutableImage#set! instead.
812 813 814 |
# File 'lib/vips/image.rb', line 812 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.
706 707 708 |
# File 'lib/vips/image.rb', line 706 def set_kill kill Vips.vips_image_set_kill self, kill end |
#set_progress(state) ⇒ Object
Turn progress signalling on and off.
If this is on, the most-downstream image from this image will issue progress signals.
695 696 697 |
# File 'lib/vips/image.rb', line 695 def set_progress state Vips.vips_image_set_progress self, state end |
#set_type(gtype, name, value) ⇒ Object
This method is deprecated.
Please use MutableImage#set_type! instead.
801 802 803 804 805 806 807 |
# File 'lib/vips/image.rb', line 801 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.
831 832 833 |
# File 'lib/vips/image.rb', line 831 def set_value name, value set name, value end |
#shrink(hshrink, vshrink, **opts) ⇒ Vips::Image
Shrink an image.
|
# File 'lib/vips/methods.rb', line 2292
|
#shrinkh(hshrink, **opts) ⇒ Vips::Image
Shrink an image horizontally.
|
# File 'lib/vips/methods.rb', line 2301
|
#shrinkv(vshrink, **opts) ⇒ Vips::Image
Shrink an image vertically.
|
# File 'lib/vips/methods.rb', line 2308
|
#similarity(**opts) ⇒ Vips::Image
Similarity transform of an image.
|
# File 'lib/vips/methods.rb', line 2366
|
#sin ⇒ Image
Return the sine of an image in degrees.
1398 1399 1400 |
# File 'lib/vips/image.rb', line 1398 def sin math :sin end |
#size ⇒ Integer
Get the image size.
933 934 935 |
# File 'lib/vips/image.rb', line 933 def size [width, height] end |
#smartcrop(width, height, **opts) ⇒ Vips::Image
Extract an area from an image.
|
# File 'lib/vips/methods.rb', line 396
|
#spectrum(**opts) ⇒ Vips::Image
Make displayable power spectrum.
|
# File 'lib/vips/methods.rb', line 2793
|
#sRGB2scRGB(**opts) ⇒ Vips::Image
Convert an srgb image to scrgb.
|
# File 'lib/vips/methods.rb', line 2567
|
#stdif(width, height, **opts) ⇒ Vips::Image
Statistical difference.
|
# File 'lib/vips/methods.rb', line 2619
|
#subsample(xfac, yfac, **opts) ⇒ Vips::Image
Subsample an image.
|
# File 'lib/vips/methods.rb', line 534
|
#tan ⇒ Image
Return the tangent of an image in degrees.
1412 1413 1414 |
# File 'lib/vips/image.rb', line 1412 def tan math :tan end |
#thumbnail_image(width, **opts) ⇒ Vips::Image
Generate thumbnail from image.
|
# File 'lib/vips/methods.rb', line 2253
|
#tiffsave(filename, **opts) ⇒ nil
Save image to tiff file.
|
# File 'lib/vips/methods.rb', line 2073
|
#tiffsave_buffer(**opts) ⇒ VipsBlob
Save image to tiff buffer.
|
# File 'lib/vips/methods.rb', line 2105
|
#tilecache(**opts) ⇒ Vips::Image
Cache an image as a set of tiles.
|
# File 'lib/vips/methods.rb', line 281
|
#to_a ⇒ Array
Convert to an Array. This will be slow for large images.
1207 1208 1209 |
# File 'lib/vips/image.rb', line 1207 def to_a to_enum.to_a end |
#to_enum ⇒ Enumerator
Convert to an Enumerator. Similar to #to_a
but lazier.
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'lib/vips/image.rb', line 1178 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 |
#unpremultiply(**opts) ⇒ Vips::Image
Unpremultiply image alpha.
|
# File 'lib/vips/methods.rb', line 499
|
#vipssave(filename, **opts) ⇒ nil
Save image to file in vips format.
|
# File 'lib/vips/methods.rb', line 1684
|
#vipssave_target(target, **opts) ⇒ nil
Save image to target in vips format.
|
# File 'lib/vips/methods.rb', line 1693
|
#webpsave(filename, **opts) ⇒ nil
Save image to webp file.
|
# File 'lib/vips/methods.rb', line 2014
|
#webpsave_buffer(**opts) ⇒ VipsBlob
Save image to webp buffer.
|
# File 'lib/vips/methods.rb', line 2034
|
#webpsave_target(target, **opts) ⇒ nil
Save image to webp target.
|
# File 'lib/vips/methods.rb', line 2053
|
#width ⇒ Integer
Get image width, in pixels.
838 839 840 |
# File 'lib/vips/image.rb', line 838 def width Vips.vips_image_get_width self end |
#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.
622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/vips/image.rb', line 622 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.(format_string)) 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? 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.
584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/vips/image.rb', line 584 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.(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_memory ⇒ String
Write this image to a large memory buffer.
677 678 679 680 681 682 683 684 685 686 |
# File 'lib/vips/image.rb', line 677 def write_to_memory len = Vips::SizeStruct.new ptr = Vips.vips_image_write_to_memory self, len raise Vips::Error if ptr.nil? # wrap up as an autopointer ptr = FFI::AutoPointer.new(ptr, GLib::G_FREE) 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.
663 664 665 666 667 668 669 670 671 672 |
# File 'lib/vips/image.rb', line 663 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.(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 |
#xoffset ⇒ Integer
Get image xoffset.
887 888 889 |
# File 'lib/vips/image.rb', line 887 def xoffset get "xoffset" end |
#xres ⇒ Float
Get image x resolution.
901 902 903 |
# File 'lib/vips/image.rb', line 901 def xres get "xres" end |
#yoffset ⇒ Integer
Get image yoffset.
894 895 896 |
# File 'lib/vips/image.rb', line 894 def yoffset get "yoffset" end |
#yres ⇒ Float
Get image y resolution.
908 909 910 |
# File 'lib/vips/image.rb', line 908 def yres get "yres" end |
#|(other) ⇒ Image
Integer bitwise OR with an image, constant or array.
1054 1055 1056 |
# File 'lib/vips/image.rb', line 1054 def | other call_enum "boolean", other, :or end |
#~ ⇒ Image
Equivalent to image ^ -1
1084 1085 1086 |
# File 'lib/vips/image.rb', line 1084 def ~ self ^ -1 end |