Created
December 29, 2017 20:41
-
-
Save aferrero2707/76d8ddeab88dd46a468746ef792dae1b to your computer and use it in GitHub Desktop.
Benchmark code for vips_resize() function
This file contains hidden or 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
/* 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, µs); | |
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