---
name: "im_meta_set"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_meta"
---

# im\_meta\_set(3)

read and write extra header fields

Part of [im\_meta(3)](/im_meta/3.md).

## NAME

im\_meta\_set\_int, im\_meta\_get\_int, im\_meta\_set\_double, im\_meta\_get\_double, im\_meta\_set\_area, im\_meta\_get\_area, im\_meta\_set\_string, im\_meta\_get\_string, im\_meta\_set\_blob, im\_meta\_get\_blob, im\_meta\_set, im\_meta\_get - read and write extra header fields

## SYNOPSIS

\#include \<vips/vips.h\>

int im\_meta\_set\_int( IMAGE \*im, const char \*field, int i );\
 int im\_meta\_get\_int( IMAGE \*im, const char \*field, int \*i );\
 int im\_meta\_set\_double( IMAGE \*im, const char \*field, double d );\
 int im\_meta\_get\_double( IMAGE \*im, const char \*field, double \*d );\
 int im\_meta\_set\_area( IMAGE \*im, const char \*field, \
   im\_callback\_fn free\_fn, void \*data );\
 int im\_meta\_get\_area( IMAGE \*im, const char \*field, void \*\*data );\
 int im\_meta\_set\_string( IMAGE \*im, const char \*field, \
   const char \*str );\
 int im\_meta\_get\_string( IMAGE \*im, const char \*field, char \*\*str );\
 int im\_meta\_set\_blob( IMAGE \*im, const char \*field, \
   im\_callback\_fn free\_fn, void \*blob, size\_t blob\_length );\
 int im\_meta\_get\_blob( IMAGE \*im, const char \*field, \
   void \*\*blob, size\_t \*blob\_length );

typedef int (\*im\_callback\_fn)( void \*, void \* );

int im\_meta\_set( IMAGE \*im, const char \*field, GValue \*value );\
 int im\_meta\_get( IMAGE \*im, const char \*field, GValue \*value\_copy );\
 GType im\_meta\_get\_type( IMAGE \*im, const char \*field );

\#define IM\_TYPE\_SAVE\_STRING (im\_save\_string\_get\_type())\
 GType im\_save\_string\_get\_type( void );\
 const char \*im\_save\_string\_get( const GValue \*value );\
 void im\_save\_string\_set( GValue \*value, const char \*str );\
 void im\_save\_string\_setf( GValue \*value, const char \*fmt, ... );

## DESCRIPTION

These functions read and write extra image header fields. Writing to a field destroys any old value. You must read a field with the correct type of reader: you can't read an int field as a string. Fields are copied when images are processed, so you can use them to pass information to subsequent operations. Unless otherwise noted, image header fields created with these functions are also saved to disc when an image is saved in VIPS format, and automatically restored when the image is loaded again.

**[im\_meta\_set\_int(3)](/im_meta_set_int/3.md)** sets an integer field. Any existing field of any type with this name is  removed. It returns 0 for success, or -1 on error setting  **[im\_error(3)](/im_error/3.md).**

**[im\_meta\_get\_int(3)](/im_meta_get_int/3.md)** reads an integer field. It returns 0 for success, or -1 on error, setting **[im\_error(3)](/im_error/3.md).** It can fail if the field does not exist, or if the field is not an int.

**[im\_meta\_set\_double(3)](/im_meta_set_double/3.md)** and **[im\_meta\_get\_double(3)](/im_meta_get_double/3.md)** work exactly as  **[im\_meta\_set\_int(3)](/im_meta_set_int/3.md)** and **[im\_meta\_get\_int(3)](/im_meta_get_int/3.md).**

**[im\_meta\_set\_area(3)](/im_meta_set_area/3.md)** sets a field which is an area of memory. When the field is copied to a subsequent IMAGE, VIPS just copies the pointer. VIPS keeps a reference count and when the last IMAGE using this field is closed, VIPS will call  **free\_fn** to release the memory. You can therefore use this function to attach very large areas of memory to images efficiently. Areas cannot be saved to VIPS files on disc, since there is no known length.

**[im\_meta\_set\_string(3)](/im_meta_set_string/3.md)** is a convenience function over  **[im\_meta\_set\_area(3)](/im_meta_set_area/3.md).** It copies the string, and then shares that copy between all images derived from this IMAGE.

**[im\_meta\_get\_string(3)](/im_meta_get_string/3.md)** is a convenience function over  **[im\_meta\_get\_area(3)](/im_meta_get_area/3.md).** It returns a pointer to the string being mananged by VIPS. Do not free the return result!

**[im\_meta\_set\_blob(3)](/im_meta_set_blob/3.md)** sets a field which is a blob (binary object). A blob is just like string,  except that rather than being NULL-terminated, you must pass an explicit  length.

**[im\_meta\_set(3)](/im_meta_set/3.md),** **[im\_meta\_get\_type(3)](/im_meta_get_type/3.md)** and **[im\_meta\_get(3)](/im_meta_get/3.md)** operate at a lower level: they let you set image header fields as GValue. Use one of the convenience functions above if possible.  **[im\_meta\_get\_type(3)](/im_meta_get_type/3.md)** returns 0 if the field is not defined.

In order for the autoload/save to VIPS files to work, you need to use a GType with a transform defined to and from  **IM\_TYPE\_SAVE\_STRING.**

## RETURN VALUE

The functions return 0 success and -1 on error.

## SEE ALSO

[im\_header\_int(3)](/im_header_int/3.md), [im\_header\_map(3)](/im_header_map/3.md).

## COPYRIGHT

The National Gallery, 2005.

## AUTHOR

Markus Wollgarten and John Cupitt
