Skip to content

Instantly share code, notes, and snippets.

@aferrero2707
Last active August 29, 2015 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aferrero2707/9834966 to your computer and use it in GitHub Desktop.
Simple test of raw image saving
/* Compile with
gcc rawsave.c `pkg-config vips --cflags --libs`
*/
#include <vips/vips.h>
int
main( int argc, char **argv )
{
VipsImage *image;
VipsImage *image2;
VipsImage *out;
if( !(image = vips_image_new_from_file( argv[1] )) )
vips_error_exit( NULL );
if( vips_rawsave( image, argv[2], NULL ) )
vips_error_exit( NULL );
vips_rawload( argv[2], &image2, image->Xsize, image->Ysize, image->Bands, NULL );
vips_copy( image2, &out,
"format", image->BandFmt,
"coding", image->Coding,
"interpretation", image->Type,
NULL );
g_object_unref( image );
g_object_unref( image2 );
vips_image_write_to_file( out, argv[3] );
g_object_unref( out );
return( 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment