Skip to content

Instantly share code, notes, and snippets.

@jcupitt
Created January 15, 2014 09:25
Show Gist options
  • Save jcupitt/8433220 to your computer and use it in GitHub Desktop.
Save jcupitt/8433220 to your computer and use it in GitHub Desktop.
try repeated save to a buffer
/* compile with
*
* gcc -g -Wall try207.c `pkg-config vips --cflags --libs`
*/
#include <stdio.h>
#include <vips/vips.h>
int
main( int argc, char **argv )
{
VipsImage *im;
int i;
if( !(im = vips_image_new_from_file( argv[1] )) )
vips_error_exit( "can't open" );
for( i = 0; i < 10; i++ ) {
void *buf;
size_t len;
if( vips_jpegsave_buffer( im, &buf, &len, NULL ) )
vips_error_exit( "save #1 failed" );
printf( "saved %zd bytes to %p\n", len, buf );
g_free( buf );
}
g_object_unref( im );
return( 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment