conversion

conversion — convert images in some way: change band format, change header, insert, extract, join

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

enum                VipsAlign;
enum                VipsAngle;
enum                VipsCacheStrategy;
enum                VipsDirection;
enum                VipsExtend;
int                 im_copy_file                        (VipsImage *in,
                                                         VipsImage *out);
int                 im_falsecolour                      (VipsImage *in,
                                                         VipsImage *out);
int                 im_gaussnoise                       (VipsImage *out,
                                                         int x,
                                                         int y,
                                                         double mean,
                                                         double sigma);
int                 im_grid                             (VipsImage *in,
                                                         VipsImage *out,
                                                         int tile_height,
                                                         int across,
                                                         int down);
int                 im_insertset                        (VipsImage *main,
                                                         VipsImage *sub,
                                                         VipsImage *out,
                                                         int n,
                                                         int *x,
                                                         int *y);
int                 im_msb                              (VipsImage *in,
                                                         VipsImage *out);
int                 im_msb_band                         (VipsImage *in,
                                                         VipsImage *out,
                                                         int band);
int                 im_scale                            (VipsImage *in,
                                                         VipsImage *out);
int                 im_scaleps                          (VipsImage *in,
                                                         VipsImage *out);
int                 im_subsample                        (VipsImage *in,
                                                         VipsImage *out,
                                                         int xshrink,
                                                         int yshrink);
int                 im_system                           (VipsImage *im,
                                                         const char *cmd,
                                                         char **out);
VipsImage *         im_system_image                     (VipsImage *im,
                                                         const char *in_format,
                                                         const char *out_format,
                                                         const char *cmd_format,
                                                         char **log);
int                 im_text                             (VipsImage *out,
                                                         const char *text,
                                                         const char *font,
                                                         int width,
                                                         int alignment,
                                                         int dpi);
int                 im_wrap                             (VipsImage *in,
                                                         VipsImage *out,
                                                         int x,
                                                         int y);
int                 im_zoom                             (VipsImage *in,
                                                         VipsImage *out,
                                                         int xfac,
                                                         int yfac);
int                 vips_bandjoin                       (VipsImage **in,
                                                         VipsImage **out,
                                                         int n,
                                                         ...);
int                 vips_bandjoin2                      (VipsImage *in1,
                                                         VipsImage *in2,
                                                         VipsImage **out,
                                                         ...);
int                 vips_bandmean                       (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_black                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_cache                          (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast                           (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsBandFormat format,
                                                         ...);
int                 vips_cast_char                      (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_complex                   (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_double                    (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_dpcomplex                 (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_float                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_int                       (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_short                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_uchar                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_uint                      (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_cast_ushort                    (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_copy                           (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_embed                          (VipsImage *in,
                                                         VipsImage **out,
                                                         int x,
                                                         int y,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_extract_area                   (VipsImage *input,
                                                         VipsImage **output,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_extract_band                   (VipsImage *input,
                                                         VipsImage **output,
                                                         int band,
                                                         ...);
int                 vips_flip                           (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsDirection direction,
                                                         ...);
int                 vips_ifthenelse                     (VipsImage *cond,
                                                         VipsImage *in1,
                                                         VipsImage *in2,
                                                         VipsImage **out,
                                                         ...);
int                 vips_insert                         (VipsImage *main,
                                                         VipsImage *sub,
                                                         VipsImage **out,
                                                         int x,
                                                         int y,
                                                         ...);
int                 vips_join                           (VipsImage *main,
                                                         VipsImage *sub,
                                                         VipsImage **out,
                                                         VipsDirection direction,
                                                         ...);
int                 vips_recomb                         (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsImage *m,
                                                         ...);
int                 vips_replicate                      (VipsImage *in,
                                                         VipsImage **out,
                                                         int across,
                                                         int down,
                                                         ...);
int                 vips_rot                            (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsAngle angle,
                                                         ...);
int                 vips_sequential                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);
int                 vips_tilecache                      (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Object Hierarchy

  GEnum
   +----VipsAlign
  GEnum
   +----VipsAngle
  GEnum
   +----VipsCacheStrategy
  GEnum
   +----VipsDirection
  GEnum
   +----VipsExtend

Description

These operations convert an image in some way. They can be split into a two main groups.

The first set of operations change an image's format in some way. You can change the band format (for example, cast to 32-bit unsigned int), form complex images from real images, convert images to matrices 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.

Details

enum VipsAlign

typedef enum {
	VIPS_ALIGN_LOW,
	VIPS_ALIGN_CENTRE,
	VIPS_ALIGN_HIGH,
	VIPS_ALIGN_LAST
} VipsAlign;

See vips_join() and so on.

Operations like vips_join() need to be told whether to align images on the low or high coordinate edge, or centre.

See also: vips_join().

VIPS_ALIGN_LOW

align low coordinate edge

VIPS_ALIGN_CENTRE

align centre

VIPS_ALIGN_HIGH

align high coordinate edge

VIPS_ALIGN_LAST


enum VipsAngle

typedef enum {
	VIPS_ANGLE_0,
	VIPS_ANGLE_90,
	VIPS_ANGLE_180,
	VIPS_ANGLE_270,
	VIPS_ANGLE_LAST
} VipsAngle;

See vips_rot() and so on.

Fixed rotate angles.

See also: vips_rot().

VIPS_ANGLE_0

no rotate

VIPS_ANGLE_90

90 degrees anti-clockwise

VIPS_ANGLE_180

180 degree rotate

VIPS_ANGLE_270

90 degrees clockwise

VIPS_ANGLE_LAST


enum VipsCacheStrategy

typedef enum {
	VIPS_CACHE_RANDOM,
	VIPS_CACHE_SEQUENTIAL,
	VIPS_CACHE_LAST
} VipsCacheStrategy;

See vips_tilecache() and friends.

Used to hint to caches about the expected access pattern. RANDOM might mean LRU eviction, SEQUENTIAL might mean top-most eviction.

See also: vips_tilecache().

VIPS_CACHE_RANDOM

expect random access

VIPS_CACHE_SEQUENTIAL

expect sequential access

VIPS_CACHE_LAST


enum VipsDirection

typedef enum {
	VIPS_DIRECTION_HORIZONTAL,
	VIPS_DIRECTION_VERTICAL,
	VIPS_DIRECTION_LAST
} VipsDirection;

See vips_flip(), vips_join() and so on.

Operations like vips_flip() need to be told whether to flip left-right or top-bottom.

See also: vips_flip(), vips_join().

VIPS_DIRECTION_HORIZONTAL

left-right

VIPS_DIRECTION_VERTICAL

top-bottom

VIPS_DIRECTION_LAST


enum VipsExtend

typedef enum {
	VIPS_EXTEND_BLACK = 0,
	VIPS_EXTEND_COPY = 1,
	VIPS_EXTEND_REPEAT = 2,
	VIPS_EXTEND_MIRROR = 3,
	VIPS_EXTEND_WHITE = 4,
	VIPS_EXTEND_LAST = 5
} VipsExtend;

See vips_embed(), vips_conv(), vips_affine() and so on.

When the edges of an image are extended, you can specify how 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 edge pixel

VIPS_EXTEND_REPEAT --- the image is tiled to fill the new area

VIPS_EXTEND_MIRROR --- the image is reflected and tiled to reduce hash edges

VIPS_EXTEND_WHITE --- new pixels are white, ie. all bits are set

We have to specify the exact value of each enum member since we have to keep these frozen for back compat with vips7.

See also: vips_embed().

VIPS_EXTEND_BLACK

extend with black (all 0) pixels

VIPS_EXTEND_COPY

copy the image edges

VIPS_EXTEND_REPEAT

repeat the whole image

VIPS_EXTEND_MIRROR

mirror the whole image

VIPS_EXTEND_WHITE

extend with white (all bits set) pixels

VIPS_EXTEND_LAST


im_copy_file ()

int                 im_copy_file                        (VipsImage *in,
                                                         VipsImage *out);

Copy an image to a disc file, then copy again to output. If the image is already a disc file, just copy straight through.

The disc file is allocated in the same way as im_system_image(). The file is automatically deleted when out is closed.

See also: im_copy(), im_system_image().

in :

input image

out :

output image

Returns :

0 on success, -1 on error

im_falsecolour ()

int                 im_falsecolour                      (VipsImage *in,
                                                         VipsImage *out);

Force in to 1 band, 8-bit, then transform to 3-band 8-bit image with a false colour map. The map is supposed to make small differences in brightness more obvious.

See also: im_maplut().

in :

input image

out :

output image

Returns :

0 on success, -1 on error

im_gaussnoise ()

int                 im_gaussnoise                       (VipsImage *out,
                                                         int x,
                                                         int y,
                                                         double mean,
                                                         double sigma);

Make a one band float image of gaussian noise with the specified distribution. The noise distribution is created by averaging 12 random numbers with the appropriate weights.

See also: im_addgnoise(), im_make_xy(), im_text(), im_black().

out :

output image

x :

output width

y :

output height

mean :

average value in output

sigma :

standard deviation in output

Returns :

0 on success, -1 on error

im_grid ()

int                 im_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 of smaller images. Volumetric or time-sequence images are often laid out like this. This image is chopped into a series of tiles, each tile_height pixels high and the width of in. The tiles are then rearranged into a grid across tiles across and down tiles down in row-major order.

See also: im_embed(), im_insert(), im_lrjoin().

in :

input image

out :

output image

tile_height :

chop into tiles this high

across :

tiles across

down :

tiles down

Returns :

0 on success, -1 on error

im_insertset ()

int                 im_insertset                        (VipsImage *main,
                                                         VipsImage *sub,
                                                         VipsImage *out,
                                                         int n,
                                                         int *x,
                                                         int *y);

Insert sub repeatedly into main at the positions listed in the arrays x, y of length n. out is the same size as main. sub is clipped against the edges of main.

This operation is fast for large n, but will use a memory buffer the size of out. It's useful for things like making scatter plots.

If the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together, and then the two n-band images are operated upon.

The two input images are cast up to the smallest common type (see table Smallest common format in arithmetic).

See also: im_insert(), im_lrjoin().

main :

big image

sub :

small image

out :

output image

n :

number of positions

x :

left positions of sub

y :

top positions of sub

Returns :

0 on success, -1 on error

im_msb ()

int                 im_msb                              (VipsImage *in,
                                                         VipsImage *out);

Turn any integer image to 8-bit unsigned char by discarding all but the most significant byte. Signed values are converted to unsigned by adding 128.

This operator also works for LABQ coding.

See also: im_msb_band().

in :

input image

out :

output image

Returns :

0 on success, -1 on error

im_msb_band ()

int                 im_msb_band                         (VipsImage *in,
                                                         VipsImage *out,
                                                         int band);

Turn any integer image to a single-band 8-bit unsigned char by discarding all but the most significant byte from the selected band. Signed values are converted to unsigned by adding 128.

This operator also works for LABQ coding.

See also: im_msb_band().

in :

input image

out :

output image

band :

select this band

Returns :

0 on success, -1 on error

im_scale ()

int                 im_scale                            (VipsImage *in,
                                                         VipsImage *out);

Search the image for the maximum and minimum value, then return the image as unsigned 8-bit, scaled so that the maximum value is 255 and the minimum is zero.

See also: im_clip2fmt(), im_scaleps().

in :

input image

out :

output image

Returns :

0 on success, -1 on error

im_scaleps ()

int                 im_scaleps                          (VipsImage *in,
                                                         VipsImage *out);

Scale a power spectrum. Transform with log10(1.0 + pow(x, 0.25)) + .5, then scale so max == 255.

See also: im_scale().

in :

input image

out :

output image

Returns :

0 on success, -1 on error

im_subsample ()

int                 im_subsample                        (VipsImage *in,
                                                         VipsImage *out,
                                                         int xshrink,
                                                         int yshrink);

Subsample an image by an integer fraction. This is fast nearest-neighbour shrink.

See also: im_shrink(), im_affinei(), im_zoom().

in :

input image

out :

output image

xshrink :

horizontal shrink factor

yshrink :

vertical shrink factor

Returns :

0 on success, -1 on error.

im_system ()

int                 im_system                           (VipsImage *im,
                                                         const char *cmd,
                                                         char **out);

im_system() runs a command on an image, returning the command's output as a string. The command is executed with popen(), the first '%s' in the command being substituted for a filename.

If the IMAGE is a file on disc, then the filename will be the name of the real file. If the image is in memory, or the result of a computation, then a new file is created in the temporary area called something like "vips_XXXXXX.v", and that filename given to the command. The file is deleted when the command finishes.

See im_system_image() for details on how VIPS selects a temporary directory.

In all cases, log must be freed with im_free().

See also: im_system_image().

im :

image to run command on

cmd :

command to run

out :

stdout of command is returned here

Returns :

0 on success, -1 on error

im_system_image ()

VipsImage *         im_system_image                     (VipsImage *im,
                                                         const char *in_format,
                                                         const char *out_format,
                                                         const char *cmd_format,
                                                         char **log);

im_system_image() runs a command, passing an image in and getting an image back. The command's stdout is returned in log.

First, im is written to a file. The filename is formed by substituting something like "vips-49857-1" for the first %s in in_format, then prepending "/tmp". If the environment variable TMPDIR is defined, it can be used to set a different temporary directory. If in_format is something like "%s.png", the file will be written in PNG format.

On Windows, if the environment variable TMPDIR is not defined, VIPS calls GetTempPath() to get the user's preferred temporary area. If that fails, it defaults to C:\temp.

Next an output filename is created in the same way using out_format. The command string to run is made by substituting the first %s in cmd_format for the name of the input file and the second %s for the output filename.

The command is executed with popen() and the output captured in log. If the command fails, the temporary files are deleted and im_system_image() returns NULL. log is still set.

If the command succeeds, the input file is deleted, the output file opened, and returned. Closing the output image will automatically delete the file.

In all cases, log must be freed with im_free().

For example, this call will run the ImageMagick convert program on an image, using JPEG files to pass images into and out of the convert command.

1
2
3
im_system_image( in, out, 
  "%s.jpg", "%s.jpg", "convert %s -swirl 45 %s", 
  &log )

See also: im_system().

im :

image to run command on

in_format :

write input file like this

out_format :

write output filename like this

cmd_format :

command to run

log :

stdout of command is returned here

Returns :

an image on success, NULL on error. [transfer full]

im_text ()

int                 im_text                             (VipsImage *out,
                                                         const char *text,
                                                         const char *font,
                                                         int width,
                                                         int alignment,
                                                         int dpi);

Draw the string text to an image. out is a one-band 8-bit unsigned char image, with 0 for no text and 255 for text. Values inbetween are used for anti-aliasing.

text is the text to render as a UTF-8 string. It can contain Pango markup, for example "<i>The</i>Guardian".

font is the font to render with, selected by fontconfig. Examples might be "sans 12" or perhaps "bitstream charter bold 10".

width is the maximum number of pixels across to draw within. If the generated text is wider than this, it will wrap to a new line. In this case, alignment can be used to set the alignment style for multi-line text. 0 means left-align, 1 centre, 2 right-align.

dpi sets the resolution to render at. "sans 12" at 72 dpi draws characters approximately 12 pixels high.

See also: im_make_xy(), im_black(), im_gaussnoise().

out :

output image

text :

utf-8 text string to render

font :

font to render with

width :

render within this many pixels across

alignment :

left/centre/right alignment

dpi :

render at this resolution

Returns :

0 on success, -1 on error

im_wrap ()

int                 im_wrap                             (VipsImage *in,
                                                         VipsImage *out,
                                                         int x,
                                                         int y);

Slice an image up and move the segments about so that the pixel that was at 0, 0 is now at x, y.

See also: im_embed(), im_replicate(), im_rotquad().

in :

input image

out :

output image

x :

horizontal displacement

y :

vertical displacement

Returns :

0 on success, -1 on error

im_zoom ()

int                 im_zoom                             (VipsImage *in,
                                                         VipsImage *out,
                                                         int xfac,
                                                         int yfac);

Zoom an image by repeating pixels. This is fast nearest-neighbour zoom.

See also: im_affinei(), im_subsample().

in :

input image

out :

output image

xfac :

horizontal scale factor

yfac :

vertical scale factor

Returns :

0 on success, -1 on error.

vips_bandjoin ()

int                 vips_bandjoin                       (VipsImage **in,
                                                         VipsImage **out,
                                                         int n,
                                                         ...);

Join a set of images together, bandwise.

If the images have n and m bands, then the output image will have n + m bands, with the first n coming from the first image and the last m from the second.

If the images differ in size, the smaller images are enlarged to match the larger by adding zero pixels along the bottom and right.

The input images are cast up to the smallest common type (see table Smallest common format in arithmetic).

See also: vips_insert().

in :

array of input images

out :

output image

n :

number of input images

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_bandjoin2 ()

int                 vips_bandjoin2                      (VipsImage *in1,
                                                         VipsImage *in2,
                                                         VipsImage **out,
                                                         ...);

Join a pair of images together, bandwise. See vips_bandjoin().

in1 :

first input image

in2 :

second input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_bandmean ()

int                 vips_bandmean                       (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

This operation writes a one-band image where each pixel is the average of the bands for that pixel in the input image. The output band format is the same as the input band format. Integer types use round-to-nearest averaging.

See also: vips_add(), vips_avg(), vips_recomb()

in :

input IMAGE

out :

output IMAGE

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_black ()

int                 vips_black                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

bands: output bands

Make a black unsigned char image of a specified size.

See also: im_make_xy(), im_text(), im_gaussnoise().

out :

output image

width :

output width

height :

output height

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cache ()

int                 vips_cache                          (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

This operation behaves rather like vips_copy() between images in and out, except that it keeps a cache of computed pixels. This cache is made of up to max_tiles tiles (a value of -1 means any number of tiles), and each tile is of size tile_width by tile_height pixels. By default it will cache 250 128 x 128 pixel tiles, enough for two 1920 x 1080 images.

This operation is a thin wrapper over vips_sink_screen(), see the documentation for that operation for details.

It uses a set of background threads to calculate pixels and the various active cache operations coordinate so as not to overwhelm your system.

See also: vips_tilecache().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_cast ()

int                 vips_cast                           (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsBandFormat format,
                                                         ...);

Convert in to format. 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.

See also: im_scale(), im_ri2c().

in :

input image

out :

output image

format :

format to convert to

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_char ()

int                 vips_cast_char                      (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_CHAR. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_complex ()

int                 vips_cast_complex                   (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_COMPLEX. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_double ()

int                 vips_cast_double                    (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_DOUBLE. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_dpcomplex ()

int                 vips_cast_dpcomplex                 (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_DPCOMPLEX. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_float ()

int                 vips_cast_float                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_FLOAT. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_int ()

int                 vips_cast_int                       (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_INT. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_short ()

int                 vips_cast_short                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_SHORT. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_uchar ()

int                 vips_cast_uchar                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_UCHAR. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_uint ()

int                 vips_cast_uint                      (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_UINT. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_cast_ushort ()

int                 vips_cast_ushort                    (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Convert in to VIPS_FORMAT_USHORT. See vips_cast().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_copy ()

int                 vips_copy                           (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

Optional arguments:

width: set image width height: set image height bands: set image bands format: set image format coding: set image coding interpretation: set image interpretation xres: set image xres yres: set image yres xoffset: set image xoffset yoffset: set image yoffset swap: swap byte order

Copy an image, optionally modifying the header. VIPS copies images by copying pointers, so this operation is instant, even for very large images.

You can optionally set any or all header fields during the copy. Some header fields, such as "xres", the horizontal resolution, are safe to change in any way, others, such as "width" will cause immediate crashes if they are not set carefully.

Setting swap to TRUE will make vips_copy() swap the byte ordering of pixels according to the image's format.

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_embed ()

int                 vips_embed                          (VipsImage *in,
                                                         VipsImage **out,
                                                         int x,
                                                         int y,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

extend: how to generate the edge pixels

The opposite of vips_extract_area(): embed in within an image of size width by height at position x, y. extend controls what appears in the new pels, see VipsExtend.

See also: vips_extract_area(), vips_insert().

in :

input image

out :

output image

x :

place in at this x position in out

y :

place in at this y position in out

width :

out should be this many pixels across

height :

out should be this many pixels down

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_extract_area ()

int                 vips_extract_area                   (VipsImage *input,
                                                         VipsImage **output,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height,
                                                         ...);

Extract an area from an image. The area must fit within in.

See also: vips_extract_bands().

in :

input image

out :

output image

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

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_extract_band ()

int                 vips_extract_band                   (VipsImage *input,
                                                         VipsImage **output,
                                                         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

band :

band to extract

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_flip ()

int                 vips_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

direction :

flip horizontally or vertically

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_ifthenelse ()

int                 vips_ifthenelse                     (VipsImage *cond,
                                                         VipsImage *in1,
                                                         VipsImage *in2,
                                                         VipsImage **out,
                                                         ...);

Optional arguments:

blend: blend smoothly between in1 and in2

This operation scans the condition image cond and uses it to select pixels from either the then image in1 or the else image in2. Non-zero means in1, 0 means in2.

Any image can have either 1 band or n bands, where n is the same for all the non-1-band images. Single band images are then effectively copied to make n-band images.

Images in1 and in2 are cast up to the smallest common format. cond is cast to uchar.

If the images differ in size, the smaller images are enlarged to match the largest by adding zero pixels along the bottom and right.

If blend is TRUE, then values in out are smoothly blended between in1 and in2 using the formula:

out = (cond / 255) * in1 + (1 - cond / 255) * in2

See also: vips_equal().

cond :

condition VipsImage

in1 :

then VipsImage

in2 :

else VipsImage

out :

output VipsImage

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_insert ()

int                 vips_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

Insert one image into another. sub is inserted into image main at position x, y relative to the top LH corner of main.

Normally out shows the whole of main. If expand is TRUE then out is made large enough to hold all of main and sub. Any areas of out not coming from either main or sub are set to background (default 0).

If sub overlaps main, sub will appear on top of main.

If the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together, and then the two n-band images are operated upon.

The two input images are cast up to the smallest common type (see table Smallest common format in arithmetic).

See also: vips_join(), vips_embed(), vips_extract_area().

main :

big image

sub :

small image

out :

output image

x :

left position of sub

y :

top position of sub

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_join ()

int                 vips_join                           (VipsImage *main,
                                                         VipsImage *sub,
                                                         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

Join in1 and in2 together, left-right or up-down depending on the value of direction.

If one is taller or wider than the other, out will be has high as the smaller. If expand is TRUE, then the output will be expanded to contain all of the input pixels.

Use align to set the edge that the images align on. By default, they align on the edge with the lower value coordinate.

Use background to set the colour of any pixels in out which are not present in either in1 or in2.

Use shim to set the spacing between the images. By default this is 0.

If the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together, and then the two n-band images are operated upon.

The two input images are cast up to the smallest common type (see table Smallest common format in arithmetic).

See also: vips_insert().

in1 :

first input image

in2 :

second input image

out :

output image

direction :

join horizontally or vertically

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_recomb ()

int                 vips_recomb                         (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsImage *m,
                                                         ...);

This operation recombines an image's bands. Each pixel in in is treated as an n-element vector, where n is the number of bands in in, and multipled by the n x m matrix m to produce the m-band image out.

out is always float, unless in is double, in which case out is double too. No complex images allowed.

It's useful for various sorts of colour space conversions.

See also: vips_bandmean().

in :

input image

out :

output image

m :

recombination matrix

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_replicate ()

int                 vips_replicate                      (VipsImage *in,
                                                         VipsImage **out,
                                                         int across,
                                                         int down,
                                                         ...);

Repeats an image many times.

See also: vips_extract().

in :

input image

out :

output image

across :

repeat input this many times across

down :

repeat input this many times down

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_rot ()

int                 vips_rot                            (VipsImage *in,
                                                         VipsImage **out,
                                                         VipsAngle angle,
                                                         ...);

Rotate in by a multiple of 90 degrees.

See also: vips_flip().

in :

input image

out :

output image

angle :

rotation angle

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_sequential ()

int                 vips_sequential                     (VipsImage *in,
                                                         VipsImage **out,
                                                         ...);

This operation behaves rather like vips_copy() between images in and out, except that it checks that pixels are only requested top-to-bottom. If an out of order request is made, it throws an exception.

This operation is handy with tilecache for loading file formats which are strictly top-to-bottom, like PNG.

See also: vips_image_cache().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

vips_tilecache ()

int                 vips_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 strategy: hint expected access pattern VipsCacheStrategy

This operation behaves rather like vips_copy() between images in and out, except that it keeps a cache of computed pixels. This cache is made of up to max_tiles tiles (a value of -1 means any number of tiles), and each tile is of size tile_width by tile_height pixels.

Each cache tile is made with a single call to vips_image_prepare().

When the cache fills, a tile is chosen for reuse. If strategy is VIPS_CACHE_RANDOM, then the least-recently-used tile is reused. If strategy is VIPS_CACHE_SEQUENTIAL, the top-most tile is reused.

By default, tile_width and tile_height are 128 pixels, and the operation will cache up to 1,000 tiles. strategy defaults to VIPS_CACHE_RANDOM.

This is a lower-level operation than vips_image_cache() since it does no subdivision and it single-threads its callee. It is suitable for caching the output of operations like exr2vips() on tiled images.

See also: vips_image_cache().

in :

input image

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error.

See Also

resample