header

header — get, set and walk image headers

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

#define             VIPS_META_EXIF_NAME
#define             VIPS_META_XMP_NAME
#define             VIPS_META_IPCT_NAME
#define             VIPS_META_ICC_NAME
#define             VIPS_META_XML
#define             VIPS_META_RESOLUTION_UNIT
#define             VIPS_META_LOADER
guint64             vips_format_sizeof                  (VipsBandFormat format);
int                 vips_image_get_width                (const VipsImage *image);
int                 vips_image_get_height               (const VipsImage *image);
int                 vips_image_get_bands                (const VipsImage *image);
VipsBandFormat      vips_image_get_format               (const VipsImage *image);
VipsCoding          vips_image_get_coding               (const VipsImage *image);
VipsInterpretation  vips_image_get_interpretation       (const VipsImage *image);
VipsInterpretation  vips_image_guess_interpretation     (const VipsImage *image);
double              vips_image_get_xres                 (const VipsImage *image);
double              vips_image_get_yres                 (const VipsImage *image);
int                 vips_image_get_xoffset              (const VipsImage *image);
int                 vips_image_get_yoffset              (const VipsImage *image);
const char *        vips_image_get_filename             (const VipsImage *image);
const char *        vips_image_get_mode                 (const VipsImage *image);
double              vips_image_get_scale                (const VipsImage *array);
double              vips_image_get_offset               (const VipsImage *array);
void *              vips_image_get_data                 (VipsImage *image);
void                vips_image_init_fields              (VipsImage *image,
                                                         int xsize,
                                                         int ysize,
                                                         int bands,
                                                         VipsBandFormat format,
                                                         VipsCoding coding,
                                                         VipsInterpretation interpretation,
                                                         double xres,
                                                         double yres);
int                 vips_image_copy_fields_array        (VipsImage *out,
                                                         VipsImage *in[]);
int                 vips_image_copy_fieldsv             (VipsImage *out,
                                                         VipsImage *in1,
                                                         ...);
int                 vips_image_copy_fields              (VipsImage *out,
                                                         VipsImage *in);
void                vips_image_set                      (VipsImage *image,
                                                         const char *field,
                                                         GValue *value);
int                 vips_image_get                      (const VipsImage *image,
                                                         const char *field,
                                                         GValue *value_copy);
int                 vips_image_get_as_string            (const VipsImage *image,
                                                         const char *field,
                                                         char **out);
GType               vips_image_get_typeof               (const VipsImage *image,
                                                         const char *field);
gboolean            vips_image_remove                   (VipsImage *image,
                                                         const char *field);
void *              (*VipsImageMapFn)                   (VipsImage *image,
                                                         const char *field,
                                                         GValue *value,
                                                         void *a);
void *              vips_image_map                      (VipsImage *image,
                                                         VipsImageMapFn fn,
                                                         void *a);
void                vips_image_set_area                 (VipsImage *image,
                                                         const char *field,
                                                         VipsCallbackFn free_fn,
                                                         void *data);
int                 vips_image_get_area                 (const VipsImage *image,
                                                         const char *field,
                                                         void **data);
void                vips_image_set_blob                 (VipsImage *image,
                                                         const char *field,
                                                         VipsCallbackFn free_fn,
                                                         void *data,
                                                         size_t length);
int                 vips_image_get_blob                 (const VipsImage *image,
                                                         const char *field,
                                                         void **data,
                                                         size_t *length);
int                 vips_image_get_int                  (const VipsImage *image,
                                                         const char *field,
                                                         int *out);
void                vips_image_set_int                  (VipsImage *image,
                                                         const char *field,
                                                         int i);
int                 vips_image_get_double               (const VipsImage *image,
                                                         const char *field,
                                                         double *out);
void                vips_image_set_double               (VipsImage *image,
                                                         const char *field,
                                                         double d);
int                 vips_image_get_string               (const VipsImage *image,
                                                         const char *field,
                                                         const char **out);
void                vips_image_set_string               (VipsImage *image,
                                                         const char *field,
                                                         const char *str);
int                 vips_image_history_printf           (VipsImage *image,
                                                         const char *format,
                                                         ...);
int                 vips_image_history_args             (VipsImage *image,
                                                         const char *name,
                                                         int argc,
                                                         char *argv[]);
const char *        vips_image_get_history              (VipsImage *image);

Description

These functions let you get at image header data (including metadata) in a uniform way. They are handy for language bindings but less useful for C users.

They first search the VIPS header fields (see image), then search for a metadata field of that name (see meta). Use vips_image_get_typeof() to test for the existance and GType of a header field.

See meta for a set of functions for adding new metadata to an image.

Details

VIPS_META_EXIF_NAME

#define VIPS_META_EXIF_NAME "exif-data"

The name that JPEG read and write operations use for the image's EXIF data.


VIPS_META_XMP_NAME

#define VIPS_META_XMP_NAME "xmp-data"

The name that JPEG read and write operations use for the image's XMP data.


VIPS_META_IPCT_NAME

#define VIPS_META_IPCT_NAME "ipct-data"

The name that JPEG read and write operations use for the image's IPCT data.


VIPS_META_ICC_NAME

#define VIPS_META_ICC_NAME "icc-profile-data"

The name we use to attach an ICC profile. The file read and write operations for TIFF, JPEG, PNG and others use this item of metadata to attach and save ICC profiles. The profile is updated by the vips_icc_transform() operations.


VIPS_META_XML

#define VIPS_META_XML "xml-header"

The original XML that was used to code the metadata after reading a VIPS format file.


VIPS_META_RESOLUTION_UNIT

#define VIPS_META_RESOLUTION_UNIT "resolution-unit"

The JPEG and TIFF read and write operations use this to record the file's preferred unit for resolution.


VIPS_META_LOADER

#define VIPS_META_LOADER "vips-loader"

Record the name of the original loader here. Handy for hinting file formats and for debugging.


vips_format_sizeof ()

guint64             vips_format_sizeof                  (VipsBandFormat format);


vips_image_get_width ()

int                 vips_image_get_width                (const VipsImage *image);


vips_image_get_height ()

int                 vips_image_get_height               (const VipsImage *image);


vips_image_get_bands ()

int                 vips_image_get_bands                (const VipsImage *image);


vips_image_get_format ()

VipsBandFormat      vips_image_get_format               (const VipsImage *image);


vips_image_get_coding ()

VipsCoding          vips_image_get_coding               (const VipsImage *image);


vips_image_get_interpretation ()

VipsInterpretation  vips_image_get_interpretation       (const VipsImage *image);


vips_image_guess_interpretation ()

VipsInterpretation  vips_image_guess_interpretation     (const VipsImage *image);


vips_image_get_xres ()

double              vips_image_get_xres                 (const VipsImage *image);


vips_image_get_yres ()

double              vips_image_get_yres                 (const VipsImage *image);


vips_image_get_xoffset ()

int                 vips_image_get_xoffset              (const VipsImage *image);


vips_image_get_yoffset ()

int                 vips_image_get_yoffset              (const VipsImage *image);


vips_image_get_filename ()

const char *        vips_image_get_filename             (const VipsImage *image);


vips_image_get_mode ()

const char *        vips_image_get_mode                 (const VipsImage *image);


vips_image_get_scale ()

double              vips_image_get_scale                (const VipsImage *array);


vips_image_get_offset ()

double              vips_image_get_offset               (const VipsImage *array);


vips_image_get_data ()

void *              vips_image_get_data                 (VipsImage *image);

Return a pointer to the image's pixel data, if possible. This can involve allocating large amounts of memory and performing a long computation. Image pixels are laid out in band-packed rows.

See also: vips_image_wio_input().

image :

image to get data for

Returns :

a pointer to pixel data, if possible.

vips_image_init_fields ()

void                vips_image_init_fields              (VipsImage *image,
                                                         int xsize,
                                                         int ysize,
                                                         int bands,
                                                         VipsBandFormat format,
                                                         VipsCoding coding,
                                                         VipsInterpretation interpretation,
                                                         double xres,
                                                         double yres);

A convenience function to set the header fields after creating an image. Normally you copy the fields from one of your input images with vips_image_copy_fields() and then make any adjustments you need, but if you are creating an image from scratch, for example im_black() or im_jpeg2vips(), you do need to set all the fields yourself.

See also: vips_image_copy_fields().

image :

image to init

xsize :

image width

ysize :

image height

bands :

image bands

format :

band format

coding :

image coding

interpretation :

image type

xres :

horizontal resolution, pixels per millimetre

yres :

vertical resolution, pixels per millimetre

vips_image_copy_fields_array ()

int                 vips_image_copy_fields_array        (VipsImage *out,
                                                         VipsImage *in[]);

Copy fields from all the input images to the output image. There must be at least one input image.

The first input image is used to set the main fields of out (width, coding and so on).

Metadata from all the images is merged on to out, with lower-numbered items overriding higher. So for example, if in[0] and in[1] both have an item called "icc-profile", it's the profile attached to in[0] that will end up on out.

Image history is completely copied from all in. out will have the history of all the input images.

See also: vips_image_copy_fieldsv(), vips_image_copy_fields().

out :

image to copy to

in :

NULL-terminated array of images to copy from

Returns :

0 on success, -1 on error.

vips_image_copy_fieldsv ()

int                 vips_image_copy_fieldsv             (VipsImage *out,
                                                         VipsImage *in1,
                                                         ...);

Copy fields from all the input images to the output image. A convenience function over vips_image_copy_fields_array().

See also: vips_image_copy_fields_array(), vips_image_copy_fields().

out :

image to copy to

in1 :

first image to copy from

Returns :

0 on success, -1 on error.

vips_image_copy_fields ()

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

Copy fields from in to out. A convenience function over vips_image_copy_fields_array().

See also: vips_image_copy_fields_array(), vips_image_copy_fieldsv().

out :

image to copy to

in :

image to copy from

Returns :

0 on success, -1 on error.

vips_image_set ()

void                vips_image_set                      (VipsImage *image,
                                                         const char *field,
                                                         GValue *value);

Set a piece of metadata on image. Any old metadata with that name is destroyed. The GValue is copied into the image, so you need to unset the value when you're done with it.

For example, to set an integer on an image (though you would use the convenience function vips_image_set_int() in practice), you would need:

1
2
3
4
5
6
7
8
9
10
11