add vips_image_get_fields()
helps bindings (which struglle with vips_image_map()) get a list of header fields works from py, but not ruby, I guess gchar** isn't a supported type for ruby-gnome see https://github.com/jcupitt/libvips/issues/533
This commit is contained in:
parent
4540a2c220
commit
85be55fe4f
@ -9,6 +9,7 @@
|
||||
- better >4gb detect for zip dzsave output [Felix Bünemann]
|
||||
- all loaders have a @fail option, meaning fail on first warning, though it
|
||||
only does anything for jpg, csv, openslide
|
||||
- add vips_image_get_fields() to help bindings
|
||||
|
||||
11/11/16 started 8.4.4
|
||||
- fix crash in vips.exe arg parsing on Windows, thanks Yury
|
||||
|
@ -170,6 +170,7 @@ gboolean vips_image_remove( VipsImage *image, const char *name );
|
||||
typedef void *(*VipsImageMapFn)( VipsImage *image,
|
||||
const char *name, GValue *value, void *a );
|
||||
void *vips_image_map( VipsImage *image, VipsImageMapFn fn, void *a );
|
||||
gchar **vips_image_get_fields( VipsImage *image );
|
||||
|
||||
void vips_image_set_area( VipsImage *image,
|
||||
const char *name, VipsCallbackFn free_fn, void *data );
|
||||
|
@ -1176,6 +1176,55 @@ vips_image_map( VipsImage *image, VipsImageMapFn fn, void *a )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
count_fields( VipsImage *image, const char *field, GValue *value, void *a )
|
||||
{
|
||||
int *n_fields = (int *) a;
|
||||
|
||||
n_fields += 1;
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
add_fields( VipsImage *image, const char *field, GValue *value, void *a )
|
||||
{
|
||||
gchar ***p = (gchar ***) a;
|
||||
|
||||
**p = g_strdup( field );
|
||||
*p += 1;
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_get_fields:
|
||||
* @image: image to get fields from
|
||||
*
|
||||
* Get a %NULL-terminated array listing all the metadata field names on @image.
|
||||
* Free the return result with g_strfreev().
|
||||
*
|
||||
* This is handy for language bindings. From C, it's usually more convenient to
|
||||
* use vips_image_map().
|
||||
*
|
||||
* Returns: (transfer full): metadata fields in image, as a %NULL-terminated
|
||||
* array.
|
||||
*/
|
||||
gchar **
|
||||
vips_image_get_fields( VipsImage *image )
|
||||
{
|
||||
int n_fields;
|
||||
gchar **fields;
|
||||
gchar **p;
|
||||
|
||||
(void) vips_image_map( image, count_fields, &n_fields );
|
||||
fields = g_new0( gchar *, n_fields + 1 );
|
||||
p = fields;
|
||||
(void) vips_image_map( image, add_fields, &p );
|
||||
|
||||
return( fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_set_area:
|
||||
* @image: image to attach the metadata to
|
||||
|
Loading…
Reference in New Issue
Block a user