Last active
May 12, 2023 09:15
-
-
Save angstyloop/b0aa0dfc04d765fc0119f59ff2e27b1d to your computer and use it in GitHub Desktop.
Print all image metadata with VIPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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