Skip to content

Instantly share code, notes, and snippets.

@angstyloop
Last active May 12, 2023 09:15
Show Gist options
  • Save angstyloop/b0aa0dfc04d765fc0119f59ff2e27b1d to your computer and use it in GitHub Desktop.
Save angstyloop/b0aa0dfc04d765fc0119f59ff2e27b1d to your computer and use it in GitHub Desktop.
Print all image metadata with VIPS
/*
Print metadata with VIPS
COMPILE
gcc -o metadata metadata.c `pkg-config --libs --cflags vips`
RUN
./metadata
The "print_field_fn" function was taken and modified from libvips/vipsheader.c
https://github.com/libvips/libvips/blob/master/tools/vipsheader.c
*/
#include <vips/vips.h>
static void *
print_field_fn( VipsImage *image, const char *field, GValue *value, void *a )
{
char str[256];
VipsBuf buf = VIPS_BUF_STATIC( str );
printf( "%s: ", field );
vips_buf_appendgv( &buf, value );
printf( "%s\n", vips_buf_all( &buf ) );
return( NULL );
}
int main( int argc, char** argv )
{
VipsImage *image;
gboolean many = FALSE;
VIPS_INIT( argv[0] );
image = vips_image_new_temp_file( "a.jpg" );
(void) vips_image_map( image, print_field_fn, NULL );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment