Top | Description | Object Hierarchy | ![]() | ![]() | ![]() | ![]() |
int | vips_shrink () |
int | vips_shrinkh () |
int | vips_shrinkv () |
int | vips_reduce () |
int | vips_reduceh () |
int | vips_reducev () |
int | vips_thumbnail () |
int | vips_thumbnail_buffer () |
int | vips_thumbnail_image () |
int | vips_thumbnail_source () |
int | vips_similarity () |
int | vips_rotate () |
int | vips_affine () |
int | vips_resize () |
int | vips_mapim () |
int | vips_quadratic () |
These operations build on each other in a set of layers.
First,vips_affine()
applies an affine transform to an image. This is anysort of 2D transform which preserves straight lines; so any combination ofstretch, sheer, rotate and translate. You supply an interpolator for it touse to generate pixels, seevips_interpolate_new()
. It will not producegood results for very large shrinks: you'll see aliasing.
vips_reduce() is likevips_affine()
, but it can only shrink images, it can'tenlarge, rotate, or skew. It's very fast and uses an adaptive kernel forinterpolation.
vips_shrink() is a fast block shrinker. It can quickly reduce images bylarge integer factors. It will give poor results for small size reductions:again, you'll see aliasing.
Next,vips_resize()
specialises in the common task of image reduce andenlarge. It strings together combinations ofvips_shrink()
,vips_reduce()
,vips_affine()
and others to implement a general, high-quality imageresizer.
Finally,vips_thumbnail()
combines load and resize in one operation, and addscolour management and correct handling of alpha transparency. Because loadand resize happen together, it can exploit tricks like JPEG and TIFFshrink-on-load, giving a (potentially) huge speedup.vips_thumbnail_image()
is only there for emergencies, don't use it unless you really have to.
As a separate thing, `vips_mapim()
can apply arbitrary 2D image transformsto an image.
intvips_shrink (VipsImage *in
,VipsImage **out
,double hshrink
,double vshrink
,...
);
Optional arguments:
ceil
: round-up output dimensions
Shrinkin
by a pair of factors with a simple box filter. For non-integerfactors,vips_shrink()
will first shrink by the integer part with a boxfilter, then usevips_reduce()
to shrink by theremaining fractional part.
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_resize()
,vips_reduce()
.
in | input image | |
out | output image. | [out] |
hshrink | horizontal shrink | |
vshrink | vertical shrink | |
... |
|
intvips_shrinkh (VipsImage *in
,VipsImage **out
,int hshrink
,...
);
Optional arguments:
ceil
: round-up output dimensions
Shrinkin
horizontally by an integer factor. Each pixel in the output isthe average of the corresponding line ofhshrink
pixels in the input.
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrinkv()
,vips_shrink()
,vips_resize()
,vips_affine()
.
in | input image | |
out | output image. | [out] |
hshrink | horizontal shrink | |
... |
|
intvips_shrinkv (VipsImage *in
,VipsImage **out
,int vshrink
,...
);
Optional arguments:
ceil
: round-up output dimensions
Shrinkin
vertically by an integer factor. Each pixel in the output isthe average of the corresponding column ofvshrink
pixels in the input.
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrinkh()
,vips_shrink()
,vips_resize()
,vips_affine()
.
in | input image | |
out | output image. | [out] |
vshrink | vertical shrink | |
... |
|
intvips_reduce (VipsImage *in
,VipsImage **out
,double hshrink
,double vshrink
,...
);
Optional arguments:
kernel
:VipsKernel to use to interpolate (default: lanczos3)
gap
: reducing gap to use (default: 0.0)
Reducein
by a pair of factors with a pair of 1D kernels. Thiswill not work well for shrink factors greater than three.
Setgap
to speed up reducing by havingvips_shrink()
to shrinkwith a box filter first. The biggergap
, the closer the resultto the fair resampling. The smallergap
, the faster resizing.The default value is 0.0 (no optimization).
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrink()
,vips_resize()
,vips_affine()
.
in | input image | |
out | output image. | [out] |
hshrink | horizontal shrink | |
vshrink | vertical shrink | |
... |
|
intvips_reduceh (VipsImage *in
,VipsImage **out
,double hshrink
,...
);
Optional arguments:
kernel
:VipsKernel to use to interpolate (default: lanczos3)
gap
: reducing gap to use (default: 0.0)
Reducein
horizontally by a float factor. The pixels inout
areinterpolated with a 1D mask generated bykernel
.
Setgap
to speed up reducing by havingvips_shrinkh()
to shrinkwith a box filter first. The biggergap
, the closer the resultto the fair resampling. The smallergap
, the faster resizing.The default value is 0.0 (no optimization).
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrink()
,vips_resize()
,vips_affine()
.
in | input image | |
out | output image. | [out] |
hshrink | horizontal reduce | |
... |
|
intvips_reducev (VipsImage *in
,VipsImage **out
,double vshrink
,...
);
Optional arguments:
kernel
:VipsKernel to use to interpolate (default: lanczos3)
gap
: reducing gap to use (default: 0.0)
Reducein
vertically by a float factor. The pixels inout
areinterpolated with a 1D mask generated bykernel
.
Setgap
to speed up reducing by havingvips_shrinkv()
to shrinkwith a box filter first. The biggergap
, the closer the resultto the fair resampling. The smallergap
, the faster resizing.The default value is 0.0 (no optimization).
This is a very low-level operation: seevips_resize()
for a moreconvenient way to resize images.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrink()
,vips_resize()
,vips_affine()
.
in | input image | |
out | output image. | [out] |
vshrink | vertical reduce | |
... |
|
intvips_thumbnail (constchar *filename
,VipsImage **out
,int width
,...
);
Optional arguments:
height
:gint
, target height in pixels
size
:VipsSize, upsize, downsize, both or force
no_rotate
:gboolean
, don't rotate upright using orientation tag
crop
:VipsInteresting, shrink and crop to fill target
linear
:gboolean
, perform shrink in linear light
import_profile
:gchararray
, fallback import ICC profile
export_profile
:gchararray
, export ICC profile
intent
:VipsIntent, rendering intent
fail_on
:VipsFailOn, load error types to fail on
Make a thumbnail from a file. Shrinking is done in three stages: using anyshrink-on-load features available in the file import library, using a blockshrink, and using a lanczos3 shrink. At least the final 200% is done withlanczos3. The output should be high quality, and the operation should bequick.
Seevips_thumbnail_buffer()
to thumbnail from a memory buffer, orvips_thumbnail_source()
to thumbnail from an arbitrary byte source.
By default, libvips will only use the first frame of animated or multipageimages. To thumbnail all pages or frames, passn=-1
to the loader infilename
, for example"x.gif[n=-1]"
.
The output image will fit within a square of sizewidth
xwidth
. You canspecify a separate height with theheight
option. Set eitherwidth
orheight
to a very large number to ignore that dimension.
If you setcrop
, then the output image will fill the whole of thewidth
xheight
rectangle, with any excess cropped away. Seevips_smartcrop()
fordetails on the cropping strategy.
Normally the operation will upsize or downsize as required to fit the imageinside or outside the target size. Ifsize
is settoVIPS_SIZE_UP, the operation will only upsize and will justcopy if asked to downsize.Ifsize
is settoVIPS_SIZE_DOWN, the operation will only downsize and will justcopy if asked to upsize.Ifsize
isVIPS_SIZE_FORCE, the image aspect ratio will be broken and theimage will be forced to fit the target.
Normally any orientation tags on the input image (such as EXIF tags) areinterpreted to rotate the image upright. If you setno_rotate
toTRUE
,these tags will not be interpreted.
Shrinking is normally done in sRGB colourspace. Setlinear
to shrink inlinear light colourspace instead. This can give better results, but canalso be far slower, since tricks like JPEG shrink-on-load cannot be used inlinear space.
If you setexport_profile
to the filename of an ICC profile, the imagewill be transformed to the target colourspace before writing to theoutput. You can also give animport_profile
which will be used if theinput image has no ICC profile, or if the profile embedded in theinput image is broken.
Useintent
to set the rendering intent for any ICC transform. The defaultisVIPS_INTENT_RELATIVE.
Usefail_on
to control the types of error that will cause loading to fail.The default isVIPS_FAIL_ON_NONE, ie. thumbnail is permissive.
See also:vips_thumbnail_buffer()
.
filename | file to read from | |
out | output image. | [out] |
width | target width in pixels | |
... |
|
intvips_thumbnail_buffer (void *buf
,size_t len
,VipsImage **out
,int width
,...
);
Optional arguments:
height
:gint
, target height in pixels
size
:VipsSize, upsize, downsize, both or force
no_rotate
:gboolean
, don't rotate upright using orientation tag
crop
:VipsInteresting, shrink and crop to fill target
linear
:gboolean
, perform shrink in linear light
import_profile
:gchararray
, fallback import ICC profile
export_profile
:gchararray
, export ICC profile
intent
:VipsIntent, rendering intent
fail_on
:VipsFailOn, load error types to fail on
option_string
:gchararray
, extra loader options
Exactly asvips_thumbnail()
, but read from a memory buffer. One extraoptional argument,option_string
, lets you pass options to the underlyingloader.
See also:vips_thumbnail()
.
buf | memory area to load. | [array length=len][element-type guint8] |
len | size of memory area. | [type gsize] |
out | output image. | [out] |
width | target width in pixels | |
... |
|
intvips_thumbnail_image (VipsImage *in
,VipsImage **out
,int width
,...
);
Optional arguments:
height
:gint
, target height in pixels
size
:VipsSize, upsize, downsize, both or force
no_rotate
:gboolean
, don't rotate upright using orientation tag
crop
:VipsInteresting, shrink and crop to fill target
linear
:gboolean
, perform shrink in linear light
import_profile
:gchararray
, fallback import ICC profile
export_profile
:gchararray
, export ICC profile
intent
:VipsIntent, rendering intent
fail_on
:VipsFailOn, load error types to fail on
Exactly asvips_thumbnail()
, but read from an existing image.
This operationis not able to exploit shrink-on-load features of image load libraries, soit can be much slower than
and produce poorer qualityoutput. Only use it if you really have to.vips_thumbnail()
See also:vips_thumbnail()
.
in | input image | |
out | output image. | [out] |
width | target width in pixels | |
... |
|
intvips_thumbnail_source (VipsSource *source
,VipsImage **out
,int width
,...
);
Optional arguments:
height
:gint
, target height in pixels
size
:VipsSize, upsize, downsize, both or force
no_rotate
:gboolean
, don't rotate upright using orientation tag
crop
:VipsInteresting, shrink and crop to fill target
linear
:gboolean
, perform shrink in linear light
import_profile
:gchararray
, fallback import ICC profile
export_profile
:gchararray
, export ICC profile
intent
:VipsIntent, rendering intent
fail_on
:VipsFailOn, load error types to fail on
option_string
:gchararray
, extra loader options
Exactly asvips_thumbnail()
, but read from a source. One extraoptional argument,option_string
, lets you pass options to the underlyingloader.
See also:vips_thumbnail()
.
source | source to thumbnail | |
out | output image. | [out] |
width | target width in pixels | |
... |
|
intvips_similarity (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
scale
:gdouble
, scale by this factor
angle
:gdouble
, rotate by this many degrees clockwise
interpolate
:VipsInterpolate, interpolate pixels with this
background
:VipsArrayDouble colour for new pixels
idx
:gdouble
, input horizontal offset
idy
:gdouble
, input vertical offset
odx
:gdouble
, output horizontal offset
ody
:gdouble
, output vertical offset
This operator callsvips_affine()
for you, calculating the matrix for theaffine transform fromscale
andangle
. Other parameters are passed on tovips_affine()
unaltered.
See also:vips_affine()
,VipsInterpolate.
intvips_rotate (VipsImage *in
,VipsImage **out
,double angle
,...
);
Optional arguments:
interpolate
:VipsInterpolate, interpolate pixels with this
background
:VipsArrayDouble colour for new pixels
idx
:gdouble
, input horizontal offset
idy
:gdouble
, input vertical offset
odx
:gdouble
, output horizontal offset
ody
:gdouble
, output vertical offset
This operator callsvips_affine()
for you, calculating the matrix for theaffine transform fromscale
andangle
. Other parameters are passed on tovips_affine()
unaltered.
See also:vips_affine()
,VipsInterpolate.
in | input image | |
out | output image. | [out] |
angle |
| |
... |
|
intvips_affine (VipsImage *in
,VipsImage **out
,double a
,double b
,double c
,double d
,...
);
Optional arguments:
interpolate
:VipsInterpolate, interpolate pixels with this
oarea
:VipsArrayInt, output rectangle
idx
:gdouble
, input horizontal offset
idy
:gdouble
, input vertical offset
odx
:gdouble
, output horizontal offset
ody
:gdouble
, output vertical offset
extend
:VipsExtend how to generate new pixels
background
:VipsArrayDouble colour for new pixels
premultiplied
:gboolean
, images are already premultiplied
This operator performs an affine transform on an image usinginterpolate
.
The transform is:
1234567 | X=@a*(x+@idx)+@b*(y+@idy)+@odxY=@c*(x+@idx)+@d*(y+@idy)+@doywhere:xandyarethecoordinatesininputimage.XandYarethecoordinatesinoutputimage.(0,0)istheupperleftcorner. |
The section of the output space defined byoarea
is written toout
.oarea
is a four-element int array of left, top, width, height.By defaultoarea
is just large enough to cover the whole of thetransformed input image.
By default, new pixels are filled withbackground
. This defaults tozero (black). You can set other extend types withextend
.VIPS_EXTEND_COPYis better for image upsizing.
interpolate
defaults to bilinear.
idx
,idy
,odx
,ody
default to zero.
Image are normally treated as unpremultiplied, so this operation can be useddirectly on PNG images. If your images have been throughvips_premultiply()
,setpremultiplied
.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
See also:vips_shrink()
,vips_resize()
,VipsInterpolate.
in | input image | |
out | output image. | [out] |
a | transformation matrix coefficient | |
b | transformation matrix coefficient | |
c | transformation matrix coefficient | |
d | transformation matrix coefficient | |
... |
|
intvips_resize (VipsImage *in
,VipsImage **out
,double scale
,...
);
Optional arguments:
vscale
:gdouble
vertical scale factor
kernel
:VipsKernel to reduce with
gap
: reducing gap to use (default: 2.0)
Resize an image.
Setgap
to speed up downsizing by havingvips_shrink()
to shrinkwith a box filter first. The biggergap
, the closer the resultto the fair resampling. The smallergap
, the faster resizing.The default value is 2.0 (very close to fair resamplingwhile still being faster in many cases).
vips_resize() normally usesVIPS_KERNEL_LANCZOS3 for the final reduce, youcan change this withkernel
. Downsizing is done with centre convention.
When upsizing (scale
> 1), the operation usesvips_affine()
withaVipsInterpolate selected depending onkernel
. It will useVipsInterpolateBicubic forVIPS_KERNEL_CUBIC and above. It adds a0.5 pixel displacement to the input pixels to get centre convention scaling.
vips_resize() normally maintains the image aspect ratio. If you setvscale
, that factor is used for the vertical scale andscale
for thehorizontal.
If either axis would drop below 1px in size, the shrink in that dimensionis limited. This breaks the image aspect ratio, but prevents errors due tofractional pixel sizes.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
This operation does not premultiply alpha. If your image has an alphachannel, you should usevips_premultiply()
on it first.
See also:vips_premultiply()
,vips_shrink()
,vips_reduce()
.
in | input image | |
out | output image. | [out] |
scale | scale factor | |
... |
|
intvips_mapim (VipsImage *in
,VipsImage **out
,VipsImage *index
,...
);
Optional arguments:
interpolate
: interpolate pixels with this
extend
:VipsExtend how to generate new pixels
background
:VipsArrayDouble colour for new pixels
premultiplied
:gboolean
, images are already premultiplied
This operator resamplesin
usingindex
to look up pixels.out
isthe same size asindex
, with each pixel being fetched from that position inin
. That is:
1 | out[x,y]=in[index[x,y]] |
Ifindex
has one band, that band must be complex. Otherwise,index
musthave two bands of any format.
Coordinates inindex
are in pixels, with (0, 0) being the top-left cornerofin
, and with y increasing down the image. Usevips_xyz()
to build indeximages.
interpolate
defaults to bilinear.
By default, new pixels are filled withbackground
. This defaults tozero (black). You can set other extend types withextend
.VIPS_EXTEND_COPYis better for image upsizing.
Image are normally treated as unpremultiplied, so this operation can be useddirectly on PNG images. If your images have been throughvips_premultiply()
,setpremultiplied
.
This operation does not change xres or yres. The image resolution needs tobe updated by the application.
Seevips_maplut()
for a 1D equivalent of this operation.
See also:vips_xyz()
,vips_affine()
,vips_resize()
,vips_maplut()
,VipsInterpolate.
in | input image | |
out | output image. | [out] |
index | index image | |
... |
|
intvips_quadratic (VipsImage *in
,VipsImage **out
,VipsImage *coeff
,...
);
Optional arguments:
interpolate
: use this interpolator (default bilinear)
This operation is unfinished and unusable, sorry.
See also:vips_affine()
.
in | input image | |
out | output image. | [out] |
coeff | horizontal quadratic | |
... |
|
The resampling kernels vips supports. Seevips_reduce()
, for example.
Controls whether an operation should upsize, downsize, both up anddownsize, or force a size.
See also:vips_thumbnail()
.