Skip to content

Instantly share code, notes, and snippets.

@aferrero2707
Created December 29, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aferrero2707/76d8ddeab88dd46a468746ef792dae1b to your computer and use it in GitHub Desktop.
Save aferrero2707/76d8ddeab88dd46a468746ef792dae1b to your computer and use it in GitHub Desktop.
Benchmark code for vips_resize() function
/* Benchmark example for vips_resize().
*/
#include <stdio.h>
#include <stdlib.h>
#include <vips/vips.h>
int
main( int argc, char **argv )
{
VipsImage* image;
VipsImage* blurred;
VipsImage* scaled;
GTimer *timer;
gdouble elapsed;
gulong micros;
if( VIPS_INIT( argv[0] ) )
vips_error_exit( "unable to start VIPS" );
if( !(image = vips_image_new_from_file( argv[1], NULL )) ) {
vips_error( "resize", "unable to load image" ); return 1;
}
blurred = image;
if( vips_gaussblur(image, &blurred, 20, NULL) ) {
vips_error( "resize", "vips_gaussblur() failed" ); return 1;
}
VIPS_UNREF(image);
scaled = blurred;
if( vips_resize( blurred, &scaled, 0.999, NULL ) ) {
vips_error( "imagedisplay", "vips_shrink() failed" ); return 1;
}
VIPS_UNREF(blurred);
/* Save the image to file
*/
timer = g_timer_new ();
vips_jpegsave( scaled, "test.jpg", "Q", 75, NULL );
elapsed = g_timer_elapsed (timer, &micros);
g_timer_destroy (timer);
printf("Jpeg image saved in %f\n", elapsed);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment