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                im_arch_type;
gboolean            im_isnative                         (im_arch_type arch);
DOUBLEMASK *        im_vips2mask                        (IMAGE *in,
                                                         const char *out);
int                 im_mask2vips                        (DOUBLEMASK *in,
                                                         IMAGE *out);
int                 im_copy_set                         (IMAGE *in,
                                                         IMAGE *out,
                                                         int type,
                                                         float xres,
                                                         float yres,
                                                         int x,
                                                         int y);
int                 im_copy_set_meta                    (IMAGE *in,
                                                         IMAGE *out,
                                                         const char *field,
                                                         GValue *meta);
int                 im_copy_morph                       (IMAGE *in,
                                                         IMAGE *out,
                                                         int Bands,
                                                         int BandFmt,
                                                         int Coding);
int                 im_copy                             (IMAGE *in,
                                                         IMAGE *out);
int                 im_copy_swap                        (IMAGE *in,
                                                         IMAGE *out);
int                 im_copy_from                        (IMAGE *in,
                                                         IMAGE *out,
                                                         im_arch_type architecture);
int                 im_copy_file                        (IMAGE *in,
                                                         IMAGE *out);
int                 im_clip2fmt                         (IMAGE *in,
                                                         IMAGE *out,
                                                         int ofmt);
int                 im_scale                            (IMAGE *in,
                                                         IMAGE *out);
int                 im_clip                             (IMAGE *in,
                                                         IMAGE *out);
int                 im_msb                              (IMAGE *in,
                                                         IMAGE *out);
int                 im_msb_band                         (IMAGE *in,
                                                         IMAGE *out,
                                                         int band);
int                 im_c2amph                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_c2rect                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_ri2c                             (IMAGE *real_in,
                                                         IMAGE *imag_in,
                                                         IMAGE *out);
int                 im_c2imag                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_c2real                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_c2ps                             (IMAGE *in,
                                                         IMAGE *out);
int                 im_scaleps                          (IMAGE *in,
                                                         IMAGE *out);
int                 im_falsecolour                      (IMAGE *in,
                                                         IMAGE *out);
int                 im_addgnoise                        (IMAGE *Param1,
                                                         IMAGE *Param2,
                                                         double Param3);
int                 im_gaussnoise                       (IMAGE *Param1,
                                                         ...,
                                                         ...,
                                                         double Param4,
                                                         double Param5);
int                 im_black                            (IMAGE *out,
                                                         int width,
                                                         int height,
                                                         int bands);
int                 im_text                             (IMAGE *out,
                                                         const char *text,
                                                         const char *font,
                                                         int width,
                                                         int alignment,
                                                         int dpi);
int                 im_extract_band                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int band);
int                 im_extract_bands                    (IMAGE *in,
                                                         IMAGE *out,
                                                         int band,
                                                         int nbands);
int                 im_extract_area                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y,
                                                         int w,
                                                         int h);
int                 im_extract_areabands                (IMAGE *in,
                                                         IMAGE *out,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height,
                                                         int band,
                                                         int nbands);
int                 im_embed                            (IMAGE *in,
                                                         IMAGE *out,
                                                         int type,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height);
int                 im_bandjoin                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_gbandjoin                        (IMAGE **in,
                                                         IMAGE *out,
                                                         int n);
int                 im_insert                           (IMAGE *main,
                                                         IMAGE *sub,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);
int                 im_insert_noexpand                  (IMAGE *main,
                                                         IMAGE *sub,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);
int                 im_insertset                        (IMAGE *main,
                                                         IMAGE *sub,
                                                         IMAGE *out,
                                                         int n,
                                                         int *x,
                                                         int *y);
int                 im_lrjoin                           (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_tbjoin                           (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_replicate                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int across,
                                                         int down);
int                 im_grid                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int tile_height,
                                                         int across,
                                                         int down);
int                 im_wrap                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);
int                 im_fliphor                          (IMAGE *in,
                                                         IMAGE *out);
int                 im_flipver                          (IMAGE *in,
                                                         IMAGE *out);
int                 im_rot90                            (IMAGE *in,
                                                         IMAGE *out);
int                 im_rot180                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_rot270                           (IMAGE *in,
                                                         IMAGE *out);
int                 im_subsample                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);
int                 im_zoom                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);
int                 im_system                           (IMAGE *im,
                                                         const char *cmd,
                                                         char **out);

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 iamges in various ways.

Details

enum im_arch_type

typedef enum {
	IM_ARCH_NATIVE,
	IM_ARCH_BYTE_SWAPPED,
	IM_ARCH_LSB_FIRST,
	IM_ARCH_MSB_FIRST
} im_arch_type;

im_isnative ()

gboolean            im_isnative                         (im_arch_type arch);

im_vips2mask ()

DOUBLEMASK *        im_vips2mask                        (IMAGE *in,
                                                         const char *out);

im_mask2vips ()

int                 im_mask2vips                        (DOUBLEMASK *in,
                                                         IMAGE *out);

im_copy_set ()

int                 im_copy_set                         (IMAGE *in,
                                                         IMAGE *out,
                                                         int type,
                                                         float xres,
                                                         float yres,
                                                         int x,
                                                         int y);

im_copy_set_meta ()

int                 im_copy_set_meta                    (IMAGE *in,
                                                         IMAGE *out,
                                                         const char *field,
                                                         GValue *meta);

im_copy_morph ()

int                 im_copy_morph                       (IMAGE *in,
                                                         IMAGE *out,
                                                         int Bands,
                                                         int BandFmt,
                                                         int Coding);

im_copy ()

int                 im_copy                             (IMAGE *in,
                                                         IMAGE *out);

im_copy_swap ()

int                 im_copy_swap                        (IMAGE *in,
                                                         IMAGE *out);

im_copy_from ()

int                 im_copy_from                        (IMAGE *in,
                                                         IMAGE *out,
                                                         im_arch_type architecture);

im_copy_file ()

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

im_clip2fmt ()

int                 im_clip2fmt                         (IMAGE *in,
                                                         IMAGE *out,
                                                         int ofmt);

im_scale ()

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

im_clip ()

int                 im_clip                             (IMAGE *in,
                                                         IMAGE *out);

im_msb ()

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

im_msb_band ()

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

im_c2amph ()

int                 im_c2amph                           (IMAGE *in,
                                                         IMAGE *out);

im_c2rect ()

int                 im_c2rect                           (IMAGE *in,
                                                         IMAGE *out);

im_ri2c ()

int                 im_ri2c                             (IMAGE *real_in,
                                                         IMAGE *imag_in,
                                                         IMAGE *out);

im_c2imag ()

int                 im_c2imag                           (IMAGE *in,
                                                         IMAGE *out);

im_c2real ()

int                 im_c2real                           (IMAGE *in,
                                                         IMAGE *out);

im_c2ps ()

int                 im_c2ps                             (IMAGE *in,
                                                         IMAGE *out);

im_scaleps ()

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

im_falsecolour ()

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

im_addgnoise ()

int                 im_addgnoise                        (IMAGE *Param1,
                                                         IMAGE *Param2,
                                                         double Param3);

im_gaussnoise ()

int                 im_gaussnoise                       (IMAGE *Param1,
                                                         ...,
                                                         ...,
                                                         double Param4,
                                                         double Param5);

im_black ()

int                 im_black                            (IMAGE *out,
                                                         int width,
                                                         int height,
                                                         int bands);

im_text ()

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

im_extract_band ()

int                 im_extract_band                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int band);

im_extract_bands ()

int                 im_extract_bands                    (IMAGE *in,
                                                         IMAGE *out,
                                                         int band,
                                                         int nbands);

im_extract_area ()

int                 im_extract_area                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y,
                                                         int w,
                                                         int h);

im_extract_areabands ()

int                 im_extract_areabands                (IMAGE *in,
                                                         IMAGE *out,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height,
                                                         int band,
                                                         int nbands);

im_embed ()

int                 im_embed                            (IMAGE *in,
                                                         IMAGE *out,
                                                         int type,
                                                         int left,
                                                         int top,
                                                         int width,
                                                         int height);

The opposite of im_extract(): embed an image within a larger image. flag controls what appears in the new pels:

0 black pels (all bytes == 0)
1 extend pels from image edge
2 repeat image
3 mirror image
4 white pels (all bytes == 255)

in :

input image

out :

output image

flag :

how to generate the edge pixels

x :

place in at this x position in out

y :

place in at this y position in out

w :

out should be this many pixels across

h :

out should be this many pixels down

Returns :

0 on success, -1 on error.

im_bandjoin ()

int                 im_bandjoin                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

im_gbandjoin ()

int                 im_gbandjoin                        (IMAGE **in,
                                                         IMAGE *out,
                                                         int n);

im_insert ()

int                 im_insert                           (IMAGE *main,
                                                         IMAGE *sub,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);

im_insert_noexpand ()

int                 im_insert_noexpand                  (IMAGE *main,
                                                         IMAGE *sub,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);

im_insertset ()

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

im_lrjoin ()

int                 im_lrjoin                           (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

im_tbjoin ()

int                 im_tbjoin                           (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

im_replicate ()

int                 im_replicate                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int across,
                                                         int down);

im_grid ()

int                 im_grid                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int tile_height,
                                                         int across,
                                                         int down);

im_wrap ()

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

im_fliphor ()

int                 im_fliphor                          (IMAGE *in,
                                                         IMAGE *out);

im_flipver ()

int                 im_flipver                          (IMAGE *in,
                                                         IMAGE *out);

im_rot90 ()

int                 im_rot90                            (IMAGE *in,
                                                         IMAGE *out);

im_rot180 ()

int                 im_rot180                           (IMAGE *in,
                                                         IMAGE *out);

im_rot270 ()

int                 im_rot270                           (IMAGE *in,
                                                         IMAGE *out);

im_subsample ()

int                 im_subsample                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);

im_zoom ()

int                 im_zoom                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int x,
                                                         int y);

im_system ()

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

See Also

resample