Top | Description | Object Hierarchy | ![]() | ![]() | ![]() | ![]() |
conversionconversion — convert images in some way: change band format, change header, insert, extract, join |
enum | VipsExtend |
enum | VipsCompassDirection |
enum | VipsDirection |
enum | VipsAlign |
enum | VipsAngle |
enum | VipsAngle45 |
enum | VipsInteresting |
enum | VipsBlendMode |
GEnum├── VipsAlign├── VipsAngle├── VipsAngle45├── VipsBlendMode├── VipsCompassDirection├── VipsDirection├── VipsExtend╰── VipsInteresting
These operations convert an image in some way. They can be split into a twomain groups.
The first set of operations change an image's format in some way. Youcan change the band format (for example, cast to 32-bit unsignedint), form complex images from real images, convert images tomatrices and back, change header fields, and a few others.
The second group move pixels about in some way. You can flip, rotate,extract, insert and join pairs of images in various ways.
intvips_copy (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
width
:gint
, set image width
height
:gint
, set image height
bands
:gint
, set image bands
format
:VipsBandFormat, set image format
coding
:VipsCoding, set image coding
interpretation
:VipsInterpretation, set image interpretation
xres
:gdouble
, set image xres
yres
:gdouble
, set image yres
xoffset
:gint
, set image xoffset
yoffset
:gint
, set image yoffset
Copy an image, optionally modifying the header. VIPS copies images bycopying pointers, so this operation is instant, even for very large images.
You can optionally change any or all header fields during the copy. You canmake any change which does not change the size of a pel, so for exampleyou can turn a 4-band uchar image into a 2-band ushort image, but youcannot change a 100 x 100 RGB image into a 300 x 100 mono image.
See also:vips_byteswap()
,vips_bandfold()
,vips_bandunfold()
.
intvips_tilecache (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
tile_width
: width of tiles in cache
tile_height
: height of tiles in cache
max_tiles
: maximum number of tiles to cache
access
: hint expected access patternVipsAccess
threaded
: allow many threads
persistent
: don't drop cache at end of computation
This operation behaves rather likevips_copy()
between imagesin
andout
, except that it keeps a cache of computed pixels.This cache is made of up tomax_tiles
tiles (a value of -1means any number of tiles), and each tile is of sizetile_width
bytile_height
pixels.
Each cache tile is made with a single call tovips_region_prepare()
.
When the cache fills, a tile is chosen for reuse. Ifaccess
isVIPS_ACCESS_RANDOM, then the least-recently-used tile is reused. Ifaccess
isVIPS_ACCESS_SEQUENTIALthe top-most tile is reused.
By default,tile_width
andtile_height
are 128 pixels, and the operationwill cache up to 1,000 tiles.access
defaults toVIPS_ACCESS_RANDOM.
Normally, only a single thread at once is allowed to calculate tiles. Ifyou setthreaded
toTRUE
,vips_tilecache()
will allow many threads tocalculate tiles at once, and share the cache between them.
Normally the cache is dropped when computation finishes. Setpersistent
toTRUE
to keep the cache between computations.
See also:vips_cache()
,vips_linecache()
.
intvips_linecache (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
access
: hint expected access patternVipsAccess
tile_height
: height of tiles in cache
threaded
: allow many threads
This operation behaves rather likevips_copy()
between imagesin
andout
, except that it keeps a cache of computed scanlines.
The number of lines cached is enough for a small amount of non-localaccess.
Each cache tile is made with a single call tovips_region_prepare()
.
When the cache fills, a tile is chosen for reuse. Ifaccess
isVIPS_ACCESS_RANDOM, then the least-recently-used tile is reused. Ifaccess
isVIPS_ACCESS_SEQUENTIAL, thenthe top-most tile is reused.access
defaults toVIPS_ACCESS_RANDOM.
tile_height
can be used to set the size of the strips thatvips_linecache()
uses. The default is 1 (a single scanline).
Normally, only a single thread at once is allowed to calculate tiles. Ifyou setthreaded
toTRUE
,vips_linecache()
will allow many threads tocalculate tiles at once and share the cache between them.
See also:vips_cache()
,vips_tilecache()
.
intvips_sequential (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
tile_height
: height of cache strips
This operation behaves rather likevips_copy()
between imagesin
andout
, except that it checks that pixels onin
are only requestedtop-to-bottom. This operation is useful for loading file formats which arestrictly top-to-bottom, like PNG.
tile_height
can be used to set the size of the tiles thatvips_sequential()
uses. The default value is 1.
See also:vips_cache()
,vips_linecache()
,vips_tilecache()
.
intvips_copy_file (VipsImage *in
,VipsImage **out
,...
);
A simple convenience function to copy an image to a file, then copyagain to output. If the image is already a file, just copy straightthrough.
The file is allocated withvips_image_new_temp_file()
.The file is automatically deleted whenout
is closed.
See also:vips_copy()
,vips_image_new_temp_file()
.
intvips_embed (VipsImage *in
,VipsImage **out
,int x
,int y
,int width
,int height
,...
);
Optional arguments:
extend
:VipsExtend to generate the edge pixels (default: black)
background
:VipsArrayDouble colour for edge pixels
The opposite ofvips_extract_area()
: embedin
within an image of sizewidth
byheight
at positionx
,y
.
extend
controls what appears in the new pels, seeVipsExtend.
See also:vips_extract_area()
,vips_insert()
.
in | input image | |
out | output image. | [out] |
x | place | |
y | place | |
width |
| |
height |
| |
... |
|
intvips_gravity (VipsImage *in
,VipsImage **out
,VipsCompassDirection direction
,int width
,int height
,...
);
Optional arguments:
extend
:VipsExtend to generate the edge pixels (default: black)
background
:VipsArrayDouble colour for edge pixels
The opposite ofvips_extract_area()
: placein
within an image of sizewidth
byheight
at a certain gravity.
extend
controls what appears in the new pels, seeVipsExtend.
See also:vips_extract_area()
,vips_insert()
.
intvips_flip (VipsImage *in
,VipsImage **out
,VipsDirection direction
,...
);
Flips an image left-right or up-down.
See also:vips_rot()
.
in | input image | |
out | output image. | [out] |
direction | flip horizontally or vertically | |
... |
|
intvips_insert (VipsImage *main
,VipsImage *sub
,VipsImage **out
,int x
,int y
,...
);
Optional arguments:
expand
: expand output to hold whole of both images
background
: colour for new pixels
Insertsub
intomain
at positionx
,y
.
Normallyout
shows the whole ofmain
. Ifexpand
isTRUE thenout
ismade large enough to hold all ofmain
andsub
.Any areas ofout
not coming fromeithermain
orsub
are set tobackground
(default 0).
Ifsub
overlapsmain
,sub
will appear on top ofmain
.
If the number of bands differs, one of the imagesmust have one band. In this case, an n-band image is formed from theone-band image by joining n copies of the one-band image together, and thenthe two n-band images are operated upon.
The two input images are cast up to the smallest common type (see tableSmallest common format in
arithmetic).See also:vips_join()
,vips_embed()
,vips_extract_area()
.
main | big image | |
sub | small image | |
out | output image. | [out] |
x | left position of | |
y | top position of | |
... |
|
intvips_join (VipsImage *in1
,VipsImage *in2
,VipsImage **out
,VipsDirection direction
,...
);
Optional arguments:
expand
:TRUE
to expand the output image to hold all of the input pixels
shim
: space between images, in pixels
background
: background ink colour
align
: low, centre or high alignment
Joinin1
andin2
together, left-right or up-down depending on the valueofdirection
.
If one is taller or wider than theother,out
will be has high as the smaller. Ifexpand
isTRUE
, thenthe output will be expanded to contain all of the input pixels.
Usealign
to set the edge that the images align on. By default, they alignon the edge with the lower value coordinate.
Usebackground
to set the colour of any pixels inout
which are notpresent in eitherin1
orin2
.
Useshim
to set the spacing between the images. By default this is 0.
If the number of bands differs, one of the imagesmust have one band. In this case, an n-band image is formed from theone-band image by joining n copies of the one-band image together, and thenthe two n-band images are operated upon.
The two input images are cast up to the smallest common type (see tableSmallest common format in
arithmetic).If you are going to be joining many thousands of images in a regulargrid,vips_arrayjoin()
is a better choice.
See also:vips_arrayjoin()
,vips_insert()
.
in1 | first input image | |
in2 | second input image | |
out | output image. | [out] |
direction | join horizontally or vertically | |
... |
|
intvips_arrayjoin (VipsImage **in
,VipsImage **out
,int n
,...
);
Optional arguments:
across
:gint
, number of images per row
shim
:gint
, space between images, in pixels
background
:VipsArrayDouble, background ink colour
halign
:VipsAlign, low, centre or high alignment
valign
:VipsAlign, low, centre or high alignment
hspacing
:gint
, horizontal distance between images
vspacing
:gint
, vertical distance between images
Lay out the images inin
in a grid. The grid isacross
images across andhowever high is necessary to use up all ofin
. Images are set downleft-to-right and top-to-bottom.across
defaults ton
.
Each input image is placed with a box of sizehspacing
byvspacing
pixels and cropped. These default to the largest width and largest heightof the input images.
Space between images is filled withbackground
. This defaults to 0(black).
Images are positioned within theirhspacing
byvspacing
box at low,centre or high coordinate values, controlled byhalign
andvalign
. Thesedefault to left-top.
Boxes are joined and separated byshim
pixels. This defaults to 0.
If the number of bands in the input images differs, all but one of theimages must have one band. In this case, an n-band image is formed from theone-band image by joining n copies of the one-band image together, and thenthe n-band images are operated upon.
The input images are cast up to the smallest common type (see tableSmallest common format in
arithmetic).vips_colourspace() can be useful for moving the images to a commoncolourspace for compositing.
See also:vips_join()
,vips_insert()
,vips_colourspace()
.
in | array of input images. | [array length=n][transfer none] |
out | output image. | [out] |
n | number of input images | |
... |
|
intvips_extract_area (VipsImage *in
,VipsImage **out
,int left
,int top
,int width
,int height
,...
);
Extract an area from an image. The area must fit withinin
.
See also:vips_extract_bands()
,vips_smartcrop()
.
in | input image | |
out | output image. | [out] |
left | left edge of area to extract | |
top | top edge of area to extract | |
width | width of area to extract | |
height | height of area to extract | |
... |
|
intvips_crop (VipsImage *in
,VipsImage **out
,int left
,int top
,int width
,int height
,...
);
A synonym forvips_extract_area()
.
See also:vips_extract_bands()
,vips_smartcrop()
.
in | input image | |
out | output image. | [out] |
left | left edge of area to extract | |
top | top edge of area to extract | |
width | width of area to extract | |
height | height of area to extract | |
... |
|
intvips_smartcrop (VipsImage *in
,VipsImage **out
,int width
,int height
,...
);
Optional arguments:
interesting
:VipsInteresting to use to find interesting areas (default:VIPS_INTERESTING_ATTENTION)
premultiplied
:gboolean
, input image already has premultiplied alpha
attention_x
:gint
, horizontal position of attention centre when using attention based cropping
attention_y
:gint
, vertical position of attention centre when using attention based cropping
Crop an image down to a specified width and height by removing boring parts.
Useinteresting
to pick the method vips uses to decide which bits of theimage should be kept.
You can test xoffset / yoffset onout
to find the location of the cropwithin the input image.
See also:vips_extract_area()
.
in | input image | |
out | output image. | [out] |
width | width of area to extract | |
height | height of area to extract | |
... |
|
intvips_extract_band (VipsImage *in
,VipsImage **out
,int band
,...
);
Optional arguments:
n
: number of bands to extract
Extract a band or bands from an image. Extracting out of range is an error.
See also:vips_extract_area()
.
in | input image | |
out | output image. | [out] |
band | band to extract | |
... |
|
intvips_replicate (VipsImage *in
,VipsImage **out
,int across
,int down
,...
);
Repeats an image many times.
See also:vips_extract_area()
.
in | input image | |
out | output image. | [out] |
across | repeat input this many times across | |
down | repeat input this many times down | |
... |
|
intvips_grid (VipsImage *in
,VipsImage **out
,int tile_height
,int across
,int down
,...
);
Chop a tall thin image up into a set of tiles, lay the tiles out in a grid.
The input image should be a very tall, thin image containing a list ofsmaller images. Volumetric or time-sequence images are often laid out likethis. This image is chopped into a series of tiles, eachtile_height
pixels high and the width ofin
. The tiles are then rearranged into a gridacross
tiles across anddown
tiles down in row-major order.
Supplyingtile_height
,across
anddown
is not strictly necessary, weonly really need two of these. Requiring three is a double-check that theimage has the expected geometry.
See also:vips_embed()
,vips_insert()
,vips_join()
.
in | input image | |
out | output image. | [out] |
tile_height | chop into tiles this high | |
across | tiles across | |
down | tiles down | |
... |
|
intvips_transpose3d (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
page_height
:gint
, size of each input page
Transpose a volumetric image.
Volumetric images are very tall, thin images, with the metadata itemVIPS_META_PAGE_HEIGHT set to the height of each sub-image.
This operation swaps the two major dimensions, so that page N in theoutput contains the Nth scanline, in order, from each input page.
You can override theVIPS_META_PAGE_HEIGHT metadata item with the optionalpage_height
parameter.
VIPS_META_PAGE_HEIGHT in the output image is the number of pages in theinput image.
See also:vips_grid()
.
intvips_wrap (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
x
: horizontal displacement
y
: vertical displacement
Slice an image up and move the segments about so that the pixel that wasat 0, 0 is now atx
,y
. Ifx
andy
are not set, they default to thecentre of the image.
See also:vips_embed()
,vips_replicate()
.
intvips_rot (VipsImage *in
,VipsImage **out
,VipsAngle angle
,...
);
Rotatein
by a multiple of 90 degrees.
Usevips_similarity()
to rotate by an arbitrary angle.vips_rot45()
isuseful for rotating convolution masks by 45 degrees.
See also:vips_flip()
,vips_similarity()
,vips_rot45()
.
in | input image | |
out | output image. | [out] |
angle | rotation angle | |
... |
|
intvips_rot90 (VipsImage *in
,VipsImage **out
,...
);
Rotatein
by 90 degrees clockwise. A convenience function overvips_rot()
.
See also:vips_rot()
.
intvips_rot180 (VipsImage *in
,VipsImage **out
,...
);
Rotatein
by 180 degrees. A convenience function overvips_rot()
.
See also:vips_rot()
.
intvips_rot270 (VipsImage *in
,VipsImage **out
,...
);
Rotatein
by 270 degrees clockwise. A convenience function overvips_rot()
.
See also:vips_rot()
.
intvips_rot45 (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
angle
:VipsAngle45 rotation angle
Rotatein
by a multiple of 45 degrees. Odd-length sides and square imagesonly.
This operation is useful for rotating convolution masks. Usevips_similarity()
to rotate images by arbitrary angles.
See also:vips_rot()
,vips_similarity()
.
voidvips_autorot_remove_angle (VipsImage *image
);
Remove the orientation tag onimage
. Also remove any exif orientation tags.You mustvips_copy()
the image before calling this function since itmodifies metadata.
intvips_autorot (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
angle
: outputVipsAngle the image was rotated by
flip
: outputgboolean
whether the image was flipped
Look at the image metadata and rotate and flip the image to make itupright. TheVIPS_META_ORIENTATION tag is removed fromout
to preventaccidental double rotation.
Readangle
to find the amount the image was rotated by. Readflip
tosee if the image was also flipped.
intvips_zoom (VipsImage *in
,VipsImage **out
,int xfac
,int yfac
,...
);
Zoom an image by repeating pixels. This is fast nearest-neighbourzoom.
See also:vips_affine()
,vips_subsample()
.
in | input image | |
out | output image. | [out] |
xfac | horizontal scale factor | |
yfac | vertical scale factor | |
... |
|
intvips_subsample (VipsImage *in
,VipsImage **out
,int xfac
,int yfac
,...
);
Optional arguments:
point
: turn on point sample mode
Subsample an image by an integer fraction. This is fast, nearest-neighbourshrink.
For small horizontal shrinks, this operation will fetch lines of pixelsfromin
and then subsample that line. For large shrinks it will fetchsingle pixels.
Ifpoint
is set,in
will always be sampled in points. This can be fasterif the previous operations in the pipeline are very slow.
See also:vips_affine()
,vips_shrink()
,vips_zoom()
.
in | input image | |
out | output image. | [out] |
xfac | horizontal shrink factor | |
yfac | vertical shrink factor | |
... |
|
intvips_cast (VipsImage *in
,VipsImage **out
,VipsBandFormat format
,...
);
Optional arguments:
shift
:gboolean
, integer values are shifted
Convertin
toformat
. You can convert between any pair of formats.Floats are truncated (not rounded). Out of range values are clipped.
Casting from complex to real returns the real part.
Ifshift
isTRUE
, integer values are shifted up and down. For example,casting from unsigned 8 bit to unsigned 16 bit wouldshift every value left by 8 bits. The bottom bit is copied into the newbits, so 255 would become 65535.
See also:vips_scale()
,vips_complexform()
,vips_real()
,vips_imag()
,vips_cast_uchar()
,vips_msb()
.
in | input image | |
out | output image. | [out] |
format | format to convert to | |
... |
|
intvips_cast_uchar (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_UCHAR. Seevips_cast()
.
intvips_cast_char (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_CHAR. Seevips_cast()
.
intvips_cast_ushort (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_USHORT. Seevips_cast()
.
intvips_cast_short (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_SHORT. Seevips_cast()
.
intvips_cast_uint (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_UINT. Seevips_cast()
.
intvips_cast_int (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_INT. Seevips_cast()
.
intvips_cast_float (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_FLOAT. Seevips_cast()
.
intvips_cast_double (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_DOUBLE. Seevips_cast()
.
intvips_cast_complex (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_COMPLEX. Seevips_cast()
.
intvips_cast_dpcomplex (VipsImage *in
,VipsImage **out
,...
);
Convertin
toVIPS_FORMAT_DPCOMPLEX. Seevips_cast()
.
intvips_scale (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
log
: log scale pixels
exp
: exponent for log scale
Search the image for the maximum and minimum value, then return the imageas unsigned 8-bit, scaled so that the maximum value is 255 and theminimum is zero.
Iflog
is set, transform with log10(1.0 + pow(x,exp
)) + .5,then scale so max == 255. By default,exp
is 0.25.
See also:vips_cast()
.
intvips_msb (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
band
:gint
, msb just this band
Turn any integer image to 8-bit unsigned char by discarding all but the mostsignificant byte. Signed values are converted to unsigned by adding 128.
Useband
to make a one-band 8-bit image.
This operator also works for LABQ coding.
See also:vips_scale()
,vips_cast()
.
intvips_byteswap (VipsImage *in
,VipsImage **out
,...
);
Swap the byte order in an image.
See also:vips_rawload()
.
intvips_bandjoin (VipsImage **in
,VipsImage **out
,int n
,...
);
Join a set of images together, bandwise.
If the imageshave n and m bands, then the output image will have n + mbands, with the first n coming from the first image and the last mfrom the second.
If the images differ in size, the smaller images are enlarged to match thelarger by adding zero pixels along the bottom and right.
The input images are cast up to the smallest common type (see tableSmallest common format in
arithmetic).See also:vips_insert()
.
in | array of input images. | [array length=n][transfer none] |
out | output image. | [out] |
n | number of input images | |
... |
|
intvips_bandjoin2 (VipsImage *in1
,VipsImage *in2
,VipsImage **out
,...
);
Join a pair of images together, bandwise. Seevips_bandjoin()
.
in1 | first input image | |
in2 | second input image | |
out | output image. | [out] |
... |
|
intvips_bandjoin_const (VipsImage *in
,VipsImage **out
,double *c
,int n
,...
);
Append a set of constant bands to an image.
See also:vips_bandjoin()
.
in | input image | |
out | output image. | [out] |
c | array of constants to append. | [array length=n] |
n | number of constants | |
... |
|
intvips_bandjoin_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Append a single constant band to an image.
in | input image | |
out | output image. | [out] |
c | constant to append | |
... |
|
intvips_bandrank (VipsImage **in
,VipsImage **out
,int n
,...
);
Optional arguments:
index
: pick this index from list of sorted values
Sorts the imagesin
band-element-wise, then outputs animage in which each band element is selected from the sorted list by theindex
parameter. For example, ifindex
is zero, then each output band element will be the minimum of all thecorresponding input band elements.
By default,index
is -1, meaning pick the median value.
It works for any uncoded, non-complex image type. Images are cast up to thesmallest common-format.
Any image can have either 1 band or n bands, where n is the same for allthe non-1-band images. Single band images are then effectively copied tomake n-band images.
Smaller input images are expanded by adding black pixels.
See also:vips_rank()
.
in | array of input images. | [array length=n] |
out | output image. | [out] |
n | number of input images | |
... |
|
intvips_bandfold (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
factor
: fold by this factor
Fold up an image horizontally: width is collapsed into bands.Usefactor
to set how much to fold by:factor
3, for example, will makethe output image three times narrower than the input, and with three timesas many bands. By default the whole of the input width is folded up.
See also:vips_csvload()
,vips_bandunfold()
.
intvips_bandunfold (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
factor
: unfold by this factor
Unfold image bands into x axis.Usefactor
to set how much to unfold by:factor
3, for example, will makethe output image three times wider than the input, and with one thirdas many bands. By default, all bands are unfolded.
See also:vips_csvload()
,vips_bandfold()
.
intvips_bandbool (VipsImage *in
,VipsImage **out
,VipsOperationBoolean boolean
,...
);
Perform various boolean operations across the bands of an image. Forexample, a three-band uchar image operated on withVIPS_OPERATION_BOOLEAN_AND will produce a one-band uchar image where eachpixel is the bitwise and of the band elements of the corresponding pixel inthe input image.
The output image is the same format as the input image for integertypes. Float types are cast to int before processing. Complex types are notsupported.
The output image always has one band.
This operation is useful in conjunction withvips_relational()
. You can useit to see if all image bands match exactly.
See also:vips_boolean_const()
.
intvips_bandand (VipsImage *in
,VipsImage **out
,...
);
PerformVIPS_OPERATION_BOOLEAN_AND on an image. Seevips_bandbool()
.
intvips_bandor (VipsImage *in
,VipsImage **out
,...
);
PerformVIPS_OPERATION_BOOLEAN_OR on an image. Seevips_bandbool()
.
intvips_bandeor (VipsImage *in
,VipsImage **out
,...
);
PerformVIPS_OPERATION_BOOLEAN_EOR on an image. Seevips_bandbool()
.
intvips_bandmean (VipsImage *in
,VipsImage **out
,...
);
This operation writes a one-band image where each pixel is the average ofthe bands for that pixel in the input image. The output band format isthe same as the input band format. Integer types use round-to-nearestaveraging.
See also:vips_add()
,vips_avg()
,vips_recomb()
intvips_recomb (VipsImage *in
,VipsImage **out
,VipsImage *m
,...
);
This operation recombines an image's bands. Each pixel inin
is treated asan n-element vector, where n is the number of bands inin
, and multiplied bythe n x m matrixm
to produce the m-band imageout
.
out
is always float, unlessin
is double, in which caseout
is doubletoo. No complex images allowed.
It's useful for various sorts of colour space conversions.
See also:vips_bandmean()
.
in | input image | |
out | output image. | [out] |
m | recombination matrix | |
... |
|
intvips_ifthenelse (VipsImage *cond
,VipsImage *in1
,VipsImage *in2
,VipsImage **out
,...
);
Optional arguments:
blend
: blend smoothly betweenin1
andin2
This operation scans the condition imagecond
and uses it to select pixels from either the then imagein1
or the elseimagein2
. Non-zero meansin1
, 0 meansin2
.
Any image can have either 1 band or n bands, where n is the same for allthe non-1-band images. Single band images are then effectively copied tomake n-band images.
Imagesin1
andin2
are cast up to the smallest common format.cond
iscast to uchar.
If the images differ in size, the smaller images are enlarged to match thelargest by adding zero pixels along the bottom and right.
Ifblend
isTRUE
, then values inout
are smoothly blended betweenin1
andin2
using the formula:
out
= (cond
/ 255) *in1
+ (1 -cond
/ 255) *in2
See also:vips_equal()
.
intvips_switch (VipsImage **tests
,VipsImage **out
,int n
,...
);
Thetests
images are evaluated and at each point the index of the firstnon-zero value is written toout
. If alltests
are false, the value(n
+ 1) is written.
Images intests
must have one band. They are expanded to thebounding box of the set of images intests
, and that size is used forout
.tests
can have up to 255 elements.
Combine withvips_case()
to make an efficient multi-wayvips_ifthenelse()
.
See also:vips_maplut()
,vips_case()
,vips_ifthenelse()
.
tests | test these images. | [array length=n] |
out | output index image. | [out] |
n | number of input images | |
... |
|
intvips_flatten (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
background
:VipsArrayDouble colour for new pixels
max_alpha
:gdouble
, maximum value for alpha
Take the last band ofin
as an alpha and use it to blend theremaining channels withbackground
.
The alpha channel is 0 -max_alpha
, wheremax_alpha
means 100% imageand 0 means 100% background.background
defaults to zero (black).
max_alpha
has the default value 255, or 65535 for images tagged asVIPS_INTERPRETATION_RGB16 orVIPS_INTERPRETATION_GREY16.
Useful for flattening PNG images to RGB.
Non-complex images only.
See also:vips_premultiply()
,vips_pngload()
.
intvips_addalpha (VipsImage *in
,VipsImage **out
,...
);
Append an alpha channel.
See also:vips_image_hasalpha()
.
intvips_premultiply (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
max_alpha
:gdouble
, maximum value for alpha
Premultiplies any alpha channel.The final band is taken to be the alphaand the bands are transformed as:
123 | alpha=clip(0,in[in.bands-1],@max_alpha);norm=alpha/@max_alpha;out=[in[0]*norm,...,in[in.bands-1]*norm,alpha]; |
So for an N-band image, the first N - 1 bands are multiplied by the clippedand normalised final band, the final band is clipped.If there is only a single band,the image is passed through unaltered.
The result isVIPS_FORMAT_FLOAT unless the input format isVIPS_FORMAT_DOUBLE, in whichcase the output is double as well.
max_alpha
has the default value 255, or 65535 for images tagged asVIPS_INTERPRETATION_RGB16 orVIPS_INTERPRETATION_GREY16.
Non-complex images only.
See also:vips_unpremultiply()
,vips_flatten()
.
intvips_unpremultiply (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
max_alpha
:gdouble
, maximum value for alpha
alpha_band
:gint
, band containing alpha data
Unpremultiplies any alpha channel.Bandalpha_band
(by default the final band) contains the alpha and allother bands are transformed as:
123456 | alpha=(int)clip(0,in[in.bands-1],@max_alpha);norm=(double)alpha/@max_alpha;if(alpha==0)out=[0,...,0,alpha];elseout=[in[0]/norm,...,in[in.bands-1]/norm,alpha]; |
So for an N-band image, the first N - 1 bands are divided by the clippedand normalised final band, the final band is clipped.If there is only a single band, the image is passed through unaltered.
The result isVIPS_FORMAT_FLOAT unless the input format isVIPS_FORMAT_DOUBLE, in whichcase the output is double as well.
max_alpha
has the default value 255, or 65535 for images tagged asVIPS_INTERPRETATION_RGB16 orVIPS_INTERPRETATION_GREY16.
Non-complex images only.
See also:vips_premultiply()
,vips_flatten()
.
intvips_composite (VipsImage **in
,VipsImage **out
,int n
,int *mode
,...
);
Optional arguments:
compositing_space
:VipsInterpretation to composite in
premultiplied
:gboolean
, images are already premultiplied
x
:VipsArrayInt, array of (n
- 1) x coordinates
y
:VipsArrayInt, array of (n
- 1) y coordinates
Composite an array of images together.
Images are placed in a stack, within
[0] at the bottom andin
[n
- 1] atthe top. Pixels are blended together working from the bottom upwards, withthe blend mode at each step being set by the correspondingVipsBlendModeinmode
.
Images are transformed to a compositing space before processing. This isVIPS_INTERPRETATION_sRGB,VIPS_INTERPRETATION_B_W,VIPS_INTERPRETATION_RGB16, orVIPS_INTERPRETATION_GREY16by default, depending onhow many bands and bits the input images have. You can select any otherspace, such asVIPS_INTERPRETATION_LAB orVIPS_INTERPRETATION_scRGB.
The output image is in the compositing space. It will always beVIPS_FORMAT_FLOAT unless one of the inputs isVIPS_FORMAT_DOUBLE, inwhich case the output will be double as well.
Complex images are not supported.
The output image will always have an alpha band. A solid alpha isadded to any input missing an alpha.
The images do not need to match in size or format. The output image isalways the size ofin
[0], with other images beingpositioned with thex
andy
parameters and clippedagainst that rectangle.
Image are normally treated as unpremultiplied, so this operation can be useddirectly on PNG images. If your images have been throughvips_premultiply()
,setpremultiplied
.
See also:vips_insert()
.
in | array of input images. | [array length=n][transfer none] |
out | output image. | [out] |
n | number of input images | |
mode | array of ( | |
... |
|
intvips_composite2 (VipsImage *base
,VipsImage *overlay
,VipsImage **out
,VipsBlendMode mode
,...
);
Optional arguments:
compositing_space
:VipsInterpretation to composite in
premultiplied
:gboolean
, images are already premultiplied
x
:gint
, position of overlay
y
:gint
, position of overlay
Compositeoverlay
on top ofbase
withmode
. Seevips_composite()
.
base | first input image | |
overlay | second input image | |
out | output image. | [out] |
mode | composite with this blend mode | |
... |
|
intvips_falsecolour (VipsImage *in
,VipsImage **out
,...
);
Forcein
to 1 band, 8-bit, then transform toa 3-band 8-bit image with a false colourmap. The map is supposed to make small differences in brightness moreobvious.
See also:vips_maplut()
.
intvips_gamma (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
exponent
: gamma, default 1.0 / 2.4
Calculatein
** (1 /exponent
), normalising to the maximum range of theinput type. For float types use 1.0 as the maximum.
Seevips_embed()
,vips_conv()
,vips_affine()
and so on.
When the edges of an image are extended, you can specifyhow you want the extension done.
VIPS_EXTEND_BLACK --- new pixels are black, ie. all bits are zero.
VIPS_EXTEND_COPY --- each new pixel takes the value of the nearest edgepixel
VIPS_EXTEND_REPEAT --- the image is tiled to fill the new area
VIPS_EXTEND_MIRROR --- the image is reflected and tiled to reduce hashedges
VIPS_EXTEND_WHITE --- new pixels are white, ie. all bits are set
VIPS_EXTEND_BACKGROUND --- colour set from thebackground
property
We have to specify the exact value of each enum member since we have tokeep these frozen for back compat with vips7.
See also:vips_embed()
.
A direction on a compass. Used forvips_gravity()
, for example.
Seevips_flip()
,vips_join()
and so on.
Operations likevips_flip()
need to be told whether to flip left-right ortop-bottom.
See also:vips_flip()
,vips_join()
.
Seevips_join()
and so on.
Operations likevips_join()
need to be told whether to align images on thelow or high coordinate edge, or centre.
See also:vips_join()
.
Seevips_rot45()
and so on.
Fixed rotate angles.
See also:vips_rot45()
.
Pick the algorithm vips uses to decide image "interestingness". This is usedbyvips_smartcrop()
, for example, to decide what parts of the image tokeep.
VIPS_INTERESTING_NONE andVIPS_INTERESTING_LOW mean the same -- thecrop is positioned at the top or left.VIPS_INTERESTING_HIGH positions atthe bottom or right.
See also:vips_smartcrop()
.
The various Porter-Duff and PDF blend modes. Seevips_composite()
,for example.
The Cairo docs have a nice explanation of all the blend modes:
https://www.cairographics.org/operators
The non-separable modes are not implemented.
where the second object is drawn, the first is removed | ||
the second object is drawn as if nothing were below | ||
the image shows what you would expect if you held two semi-transparent slides on top of each other | ||
the first object is removed completely, the second is only drawn where the first was | ||
the second is drawn only where the first isn't | ||
this leaves the first object mostly intact, but mixes both objects in the overlapping area | ||
leaves the first object untouched, the second is discarded completely | ||
like OVER, but swaps the arguments | ||
like IN, but swaps the arguments | ||
like OUT, but swaps the arguments | ||
like ATOP, but swaps the arguments | ||
something like a difference operator | ||
a bit like adding the two images | ||
a bit like the darker of the two | ||
at least as dark as the darker of the two inputs | ||
at least as light as the lighter of the inputs | ||
multiplies or screens colors, depending on the lightness | ||
the darker of each component | ||
the lighter of each component | ||
brighten first by a factor second | ||
darken first by a factor of second | ||
multiply or screen, depending on lightness | ||
darken or lighten, depending on lightness | ||
difference of the two | ||
somewhat like DIFFERENCE, but lower-contrast | ||