Top | Description | ![]() | ![]() | ![]() | ![]() |
#define | VIPS_META_EXIF_NAME |
#define | VIPS_META_XMP_NAME |
#define | VIPS_META_IPTC_NAME |
#define | VIPS_META_PHOTOSHOP_NAME |
#define | VIPS_META_ICC_NAME |
#define | VIPS_META_IMAGEDESCRIPTION |
#define | VIPS_META_RESOLUTION_UNIT |
#define | VIPS_META_BITS_PER_SAMPLE |
#define | VIPS_META_PALETTE |
#define | VIPS_META_LOADER |
#define | VIPS_META_SEQUENTIAL |
#define | VIPS_META_ORIENTATION |
#define | VIPS_META_PAGE_HEIGHT |
#define | VIPS_META_N_PAGES |
#define | VIPS_META_N_SUBIFDS |
#define | VIPS_META_CONCURRENCY |
These functions let you get at image header data (including metadata) in auniform way.
Usevips_image_get_typeof()
to test for theexistence andGType of a header field.
You can attach arbitrary metadata to images. Metadata is copied as imagesare processed, so all images which used this image as input, directly orindirectly, will have this same bit of metadata attached to them. Copyingis implemented with reference-counted pointers, so it is efficient, even forlarge items of data. This does however mean that metadata items need to beimmutable. Metadata is handy for things like ICC profiles or EXIF data.
Various convenience functions (eg.vips_image_set_int()
) let you easilyattachsimple types likenumbers, strings and memory blocks to images. Usevips_image_map()
to loopover an image's fields, including all metadata.
Items of metadata are identified by strings. Some strings are reserved, forexample the ICC profile for an image is known by convention as"icc-profile-data".
If you save an image in VIPS format, all metadata (with a restriction, seebelow) is automatically saved for you in a block of XML at the end of thefile. When you load a VIPS image, the metadata is restored. You can use thevipsedit
command-line tool to extract or replace this block of XML.
VIPS metadata is based onGValue
. See the docs for that system if you wantto do fancy stuff such as defining a new metadata type.VIPS defines a newGValue
calledvips_save_string
, a variety of string,seevips_value_set_save_string()
.If yourGValue
can be transformed tovips_save_string
, it will besaved and loaded to and from VIPS files for you.
VIPS provides a couple of base classes which implementreference-counted areas of memory. If you base your metadata on one ofthese types, it can be copied between images efficiently.
guint64vips_format_sizeof_unsafe (VipsBandFormat format
);
A fast but dangerous version ofvips_format_sizeof()
. You must havepreviously range-checkedformat
or you'll crash.
doublevips_interpretation_max_alpha (VipsInterpretation interpretation
);
VipsBandFormatvips_image_guess_format (constVipsImage *image
);
Return theVipsBandFormat for an image, guessing a sane value ifthe set value looks crazy.
For example, for a float image tagged as rgb16, we'd return ushort.
VipsInterpretationvips_image_get_interpretation (constVipsImage *image
);
Return theVipsInterpretation set in the image header.Usevips_image_guess_interpretation()
if you want a sanity-checked value.
VipsInterpretationvips_image_guess_interpretation (constVipsImage *image
);
Return theVipsInterpretation for an image, guessing a sane value ifthe set value looks crazy.
constchar *vips_image_get_mode (constVipsImage *image
);
Image modes are things like"t"
, meaning a memory buffer, and"p"
meaning a delayed computation.
doublevips_image_get_scale (constVipsImage *image
);
Matrix images can have an optionalscale
field for use by integerconvolution.
doublevips_image_get_offset (constVipsImage *image
);
Matrix images can have an optionaloffset
field for use by integerconvolution.
intvips_image_get_page_height (VipsImage *image
);
Multi-page images can have a page height. Fetch it, and sanity check it. Ifpage-height is not set, it defaults to the image height.
intvips_image_get_n_pages (VipsImage *image
);
Fetch and sanity-checkVIPS_META_N_PAGES. Default to 1 if not present orcrazy.
This is the number of pages in the image file, not the number of pages thathave been loaded intoimage
.
intvips_image_get_n_subifds (VipsImage *image
);
Fetch and sanity-checkVIPS_META_N_SUBIFDS. Default to 0 if not present orcrazy.
intvips_image_get_orientation (VipsImage *image
);
Fetch and sanity-checkVIPS_META_ORIENTATION. Default to 1 (no rotate,no flip) if not present or crazy.
gbooleanvips_image_get_orientation_swap (VipsImage *image
);
ReturnTRUE
if applying the orientation would swap width and height.
intvips_image_get_concurrency (VipsImage *image
,int default_concurrency
);
Fetch and sanity-checkVIPS_CONCURRENCY. Default to 1 if not present orcrazy.
constvoid *vips_image_get_data (VipsImage *image
);
Return a pointer to the image's pixel data, if possible. This can involveallocating large amounts of memory and performing a long computation. Imagepixels are laid out in band-packed rows.
Since this function modifiesimage
, it is not threadsafe. Only call it onimages which you are sure have not been shared with another thread.
voidvips_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 your input images withvips_image_pipelinev()
and then makeany adjustments you need, but if you are creating an image from scratch,for examplevips_black()
orvips_jpegload()
, you do need to set all thefields yourself.
See also:vips_image_pipelinev()
.
voidvips_image_set (VipsImage *image
,constchar *name
,GValue *value
);
Set a piece of metadata onimage
. Any old metadata with that name isdestroyed. TheGValue
is copied into the image, so you need to unset thevalue when you're done with it.
For example, to set an integer on an image (though you would use theconvenience functionvips_image_set_int()
in practice), you would do:
123456 | GValuevalue=G_VALUE_INIT;g_value_init(&value,G_TYPE_INT);g_value_set_int(&value,42);vips_image_set(image,name,&value);g_value_unset(&value); |
See also:vips_image_get()
.
intvips_image_get (constVipsImage *image
,constchar *name
,GValue *value_copy
);
Fillvalue_copy
with a copy of the header field.value_copy
must be zeroedbut uninitialised.
This will return -1 and add a message to the error buffer if the fielddoes not exist. Usevips_image_get_typeof()
to test for theexistence of a field first if you are not certain it will be there.
For example, to read a double from an image (though of course you would usevips_image_get_double()
in practice):
1234567891011121314151617 | GValuevalue=G_VALUE_INIT;doubled;if(vips_image_get(image,name,&value))return-1;if(G_VALUE_TYPE(&value)!=G_TYPE_DOUBLE){vips_error("mydomain",_("field\"%s\" is of type %s, not double"),name,g_type_name(G_VALUE_TYPE(&value)));g_value_unset(&value);return-1;}d=g_value_get_double(&value);g_value_unset(&value); |
See also:vips_image_get_typeof()
,vips_image_get_double()
.
image | image to get the field from from | |
name | the name to fetch | |
value_copy | the | [transfer full][out caller-allocates] |
intvips_image_get_as_string (constVipsImage *image
,constchar *name
,char **out
);
Returnsname
fromimage
inout
.This function will read any field, returning it as a printable string.You need to free the string withg_free()
when you are done with it.
This will base64-encode BLOBs, for example. Usevips_buf_appendgv()
tomake a string that's for humans.
See also:vips_image_get()
,vips_image_get_typeof()
,vips_buf_appendgv()
.
image | image to get the header field from | |
name | field name | |
out | return field value as string. | [out][transfer full] |
GTypevips_image_get_typeof (constVipsImage *image
,constchar *name
);
Read theGType
for a header field. Returns zero if there is nofield of that name.
See also:vips_image_get()
.
gbooleanvips_image_remove (VipsImage *image
,constchar *name
);
Find and remove an item of metadata. ReturnFALSE
if no metadata of thatname was found.
See also:vips_image_set()
,vips_image_get_typeof()
.
void *vips_image_map (VipsImage *image
,VipsImageMapFn fn
,void *a
);
This function callsfn
for every header field, including every item ofmetadata.
Like all _map functions, the user function should returnNULL
to continueiteration, or a non-NULL
pointer to indicate early termination.
See also:vips_image_get_typeof()
,vips_image_get()
.
image | image to map over | |
fn | function to call for each header field. | [scope call] |
a | user data for function. | [closure fn] |
gchar **vips_image_get_fields (VipsImage *image
);
Get aNULL
-terminated array listing all the metadata field names onimage
.Free the return result withg_strfreev()
.
This is handy for language bindings. From C, it's usually more convenient tousevips_image_map()
.
voidvips_image_set_area (VipsImage *image
,constchar *name
,VipsCallbackFn free_fn
,void *data
);
Attachesdata
as a metadata item onimage
under the namename
. WhenVIPS no longer needs the metadata, it will be freed withfree_fn
.
See also:vips_image_get_double()
,vips_image_set()
image | image to attach the metadata to | |
name | metadata name | |
free_fn | free function for | [scope async][nullable] |
data | pointer to area of memory. | [transfer full] |
intvips_image_get_area (constVipsImage *image
,constchar *name
,constvoid **data
);
Getsdata
fromimage
under the namename
. A conveniencefunction overvips_image_get()
. Usevips_image_get_typeof()
to test forthe existence of a piece of metadata.
See also:vips_image_set_area()
,vips_image_get()
,vips_image_get_typeof()
voidvips_image_set_blob (VipsImage *image
,constchar *name
,VipsCallbackFn free_fn
,constvoid *data
,size_t length
);
Attachesdata
as a metadata item onimage
under the namename
.
See also:vips_image_get_blob()
,vips_image_set()
.
image | image to attach the metadata to | |
name | metadata name | |
free_fn | free function for | [scope async][nullable] |
data | pointer to area ofmemory. | [array length=length][element-type guint8][transfer full] |
length | length of memory area |
voidvips_image_set_blob_copy (VipsImage *image
,constchar *name
,constvoid *data
,size_t length
);
Attachesdata
as a metadata item onimage
under the namename
, takinga copy of the memory area.
See also:vips_image_get_blob()
,vips_image_set()
.
image | image to attach the metadata to | |
name | metadata name | |
data | pointer to area of memory. | [array length=length][element-type guint8] |
length | length of memory area |
intvips_image_get_blob (constVipsImage *image
,constchar *name
,constvoid **data
,size_t *length
);
Getsdata
fromimage
under the namename
, optionally returns itslength inlength
. Usevips_image_get_typeof()
to test for the existenceof a piece of metadata.
See also:vips_image_get()
,vips_image_get_typeof()
,vips_blob_get()
,
image | image to get the metadata from | |
name | metadata name | |
data | pointer to area of memory. | [out][array length=length][element-type guint8] |
length | return the blob length here, optionally. | [out] |
intvips_image_get_int (constVipsImage *image
,constchar *name
,int *out
);
Getsout
fromim
under the namename
.The value will be transformed intoan int, if possible.
See also:vips_image_get()
,vips_image_get_typeof()
voidvips_image_set_int (VipsImage *image
,constchar *name
,int i
);
Attachesi
as a metadata item onimage
under the namename
. Aconveniencefunction overvips_image_set()
.
See also:vips_image_get_int()
,vips_image_set()
intvips_image_get_double (constVipsImage *image
,constchar *name
,double *out
);
Getsout
fromim
under the namename
.The value will be transformed intoa double, if possible.
See also:vips_image_get()
,vips_image_get_typeof()
voidvips_image_set_double (VipsImage *image
,constchar *name
,double d
);
Attachesd
as a metadata item onimage
asname
. Aconveniencefunction overvips_image_set()
.
See also:vips_image_get_double()
,vips_image_set()
intvips_image_get_string (constVipsImage *image
,constchar *name
,constchar **out
);
Getsout
fromim
under the namename
.The field must be of typeG_TYPE_STRING, VIPS_TYPE_REF_STRING.
Do not freeout
.
Usevips_image_get_as_string()
to fetch any field as a string.
See also:vips_image_get()
,vips_image_get_typeof()
image | image to get the header field from | |
name | field name | |
out | return field value. | [out][transfer none] |
voidvips_image_set_string (VipsImage *image
,constchar *name
,constchar *str
);
Attachesstr
as a metadata item onimage
asname
.A conveniencefunction overvips_image_set()
usingVIPS_TYPE_REF_STRING.
See also:vips_image_get_double()
,vips_image_set()
.
voidvips_image_print_field (constVipsImage *image
,constchar *name
);
Prints fieldname
to stdout as ASCII. Handy for debugging.
intvips_image_get_image (constVipsImage *image
,constchar *name
,VipsImage **out
);
Getsout
fromim
under the namename
.The field must be of typeVIPS_TYPE_IMAGE. You must unrefout
withg_object_unref()
.
Usevips_image_get_typeof()
to test for theexistence of a piece of metadata.
See also:vips_image_get()
,vips_image_set_image()
image | image to get the metadata from | |
name | metadata name | |
out | return metadata value. | [out][transfer full] |
voidvips_image_set_image (VipsImage *image
,constchar *name
,VipsImage *im
);
Attachesim
as a metadata item onimage
asname
.A convenience function overvips_image_set()
.
See also:vips_image_get_image()
,vips_image_set()
.
voidvips_image_set_array_int (VipsImage *image
,constchar *name
,constint *array
,int n
);
Attachesarray
as a metadata item onimage
asname
.A convenience function overvips_image_set()
.
See also:vips_image_get_image()
,vips_image_set()
.
image | image to attach the metadata to | |
name | metadata name | |
array | array of ints. | [array length=n][allow-none] |
n | the number of elements |
intvips_image_get_array_int (VipsImage *image
,constchar *name
,int **out
,int *n
);
Getsout
fromim
under the namename
.The field must be of typeVIPS_TYPE_ARRAY_INT.
Do not freeout
.out
is valid as long asimage
is valid.
Usevips_image_get_typeof()
to test for theexistence of a piece of metadata.
See also:vips_image_get()
,vips_image_set_image()
image | image to get the metadata from | |
name | metadata name | |
out | return pointer to array. | [out][array length=n][transfer none] |
n | return the number of elements here, optionally. | [out][optional] |
intvips_image_get_array_double (VipsImage *image
,constchar *name
,double **out
,int *n
);
Getsout
fromim
under the namename
.The field must be of typeVIPS_TYPE_ARRAY_INT.
Do not freeout
.out
is valid as long asimage
is valid.
Usevips_image_get_typeof()
to test for theexistence of a piece of metadata.
See also:vips_image_get()
,vips_image_set_image()
image | image to get the metadata from | |
name | metadata name | |
out | return pointer to array. | [out][array length=n][transfer none] |
n | return the number of elements here, optionally. | [out][optional] |
voidvips_image_set_array_double (VipsImage *image
,constchar *name
,constdouble *array
,int n
);
Attachesarray
as a metadata item onimage
asname
.A convenience function overvips_image_set()
.
See also:vips_image_get_image()
,vips_image_set()
.
image | image to attach the metadata to | |
name | metadata name | |
array | array of doubles. | [array length=n][allow-none] |
n | the number of elements |
intvips_image_history_printf (VipsImage *image
,constchar *format
,...
);
Add a line to the image history. Theformat
and arguments are expanded, thedate and time is appended prefixed with a hash character, and the wholestring is appended to the image history and terminated with a newline.
For example:
12 | vips_image_history_printf(image,"vips invert %s %s",in->filename,out->filename); |
Might add the string
1 | "vips invert /home/john/fred.v /home/john/jim.v # Fri Apr 3 23:30:35 2009\n" |
VIPS operations don't add history lines for you because a single action atthe application level might involve many VIPS operations. History must berecorded by the application.
intvips_image_history_args (VipsImage *image
,constchar *name
,int argc
,char *argv[]
);
Formats the name/argv as a single string and callsvips_image_history_printf()
. Aconvenience function for command-line prorams.
See also:vips_image_get_history()
.
image | image to attach history line to | |
name | program name | |
argc | number of program arguments | |
argv | program arguments. | [array length=argc][element-type char*] |
constchar *vips_image_get_history (VipsImage *image
);
This function reads the image history as a C string. The string is ownedby VIPS and must not be freed.
VIPS tracks the history of each image, that is, the sequence of operationsthat generated that image. Applications built on VIPS need to callvips_image_history_printf()
for each action they perform, setting thecommand-line equivalent for the action.
See also:vips_image_history_printf()
.
#define VIPS_META_EXIF_NAME "exif-data"
The name that read and write operations use for the image's EXIF data.
#define VIPS_META_XMP_NAME "xmp-data"
The name that read and write operations use for the image's XMP data.
#define VIPS_META_IPTC_NAME "iptc-data"
The name that read and write operations use for the image's IPTC data.
#define VIPS_META_PHOTOSHOP_NAME "photoshop-data"
The name that TIFF read and write operations use for the image'sTIFFTAG_PHOTOSHOP data.
#define VIPS_META_ICC_NAME "icc-profile-data"
The name we use to attach an ICC profile. The file read and writeoperations for TIFF, JPEG, PNG and others use this item of metadata toattach and save ICC profiles. The profile is updated by thevips_icc_transform()
operations.
#define VIPS_META_IMAGEDESCRIPTION "image-description"
The IMAGEDESCRIPTION tag. Often has useful metadata.
#define VIPS_META_RESOLUTION_UNIT "resolution-unit"
The JPEG and TIFF read and write operations use this to record thefile's preferred unit for resolution.
#define VIPS_META_BITS_PER_SAMPLE "bits-per-sample"
The bits per sample for each channel.
#define VIPS_META_LOADER "vips-loader"
Record the name of the original loader here. Handy for hinting file formatsand for debugging.
#define VIPS_META_SEQUENTIAL "vips-sequential"
Images loaded viavips_sequential()
have this int field defined. Someoperations (eg.vips_shrinkv()
) add extra caches if they see it on theirinput.
#define VIPS_META_ORIENTATION "orientation"
The orientation tag for this image. An int from 1 - 8 using the standardexif/tiff meanings.
1 - The 0th row represents the visual top of the image, and the 0th columnrepresents the visual left-hand side.
2 - The 0th row represents the visual top of the image, and the 0th columnrepresents the visual right-hand side.
3 - The 0th row represents the visual bottom of the image, and the 0thcolumn represents the visual right-hand side.
4 - The 0th row represents the visual bottom of the image, and the 0thcolumn represents the visual left-hand side.
5 - The 0th row represents the visual left-hand side of the image, and the0th column represents the visual top.
6 - The 0th row represents the visual right-hand side of the image, and the0th column represents the visual top.
7 - The 0th row represents the visual right-hand side of the image, and the0th column represents the visual bottom.
8 - The 0th row represents the visual left-hand side of the image, and the0th column represents the visual bottom.
#define VIPS_META_PAGE_HEIGHT "page-height"
If set, the height of each page when this image was loaded. If you save animage with "page-height" set to a format that supports multiple pages, suchas tiff, the image will be saved as a series of pages.
#define VIPS_META_N_PAGES "n-pages"
If set, the number of pages in the original file.
#define VIPS_META_N_SUBIFDS "n-subifds"
If set, the number of subifds in the first page of the file.