int main( int argc, char *argv[] ) { GOptionContext *context; GError *error = NULL; int i; int result; if( im_init_world( argv[0] ) ) error_exit( "unable to start VIPS" ); textdomain( GETTEXT_PACKAGE ); setlocale( LC_ALL, "" ); context = g_option_context_new( _( "- print image header" ) ); g_option_context_add_main_entries( context, main_option, GETTEXT_PACKAGE ); g_option_context_add_group( context, im_get_option_group() ); if( !g_option_context_parse( context, &argc, &argv, &error ) ) { if( error ) { fprintf( stderr, "%s\n", error->message ); g_error_free( error ); } error_exit( "try \"%s --help\"", g_get_prgname() ); } g_option_context_free( context ); result = 0; for( i = 1; i < argc; i++ ) { IMAGE *im; if( !(im = im_open( argv[i], "r" )) ) { print_error(); result = 1; } if( im && print_header( im, argc > 2 ) ) { print_error(); result = 1; } if( im ) im_close( im ); } vips_shutdown(); return( result ); }
int main( int argc, char *argv[] ) { GOptionContext *context; GError *error = NULL; int i; if( im_init_world( argv[0] ) ) error_exit( "unable to start VIPS" ); context = g_option_context_new( _( "- print image header" ) ); g_option_context_add_main_entries( context, main_option, GETTEXT_PACKAGE ); g_option_context_add_group( context, im_get_option_group() ); if( !g_option_context_parse( context, &argc, &argv, &error ) ) { if( error ) { fprintf( stderr, "%s\n", error->message ); g_error_free( error ); } error_exit( "try \"%s --help\"", g_get_prgname() ); } g_option_context_free( context ); for( i = 1; i < argc; i++ ) { IMAGE *im; if( !(im = im_open( argv[i], "r" )) ) print_error( "%s: unable to open", argv[i] ); if( im && print_header( im ) ) print_error( "%s: unable to print header", argv[i] ); if( im ) im_close( im ); } return( 0 ); }
int main( int argc, char **argv ) { GOptionContext *context; GError *error = NULL; int i; if( im_init_world( argv[0] ) ) error_exit( "unable to start VIPS" ); textdomain( GETTEXT_PACKAGE ); setlocale( LC_ALL, "" ); context = g_option_context_new( _( "- thumbnail generator" ) ); g_option_context_add_main_entries( context, options, GETTEXT_PACKAGE ); g_option_context_add_group( context, im_get_option_group() ); if( !g_option_context_parse( context, &argc, &argv, &error ) ) { if( error ) { fprintf( stderr, "%s\n", error->message ); g_error_free( error ); } error_exit( "try \"%s --help\"", g_get_prgname() ); } g_option_context_free( context ); for( i = 1; i < argc; i++ ) if( thumbnail( argv[i] ) ) { fprintf( stderr, "%s: unable to thumbnail %s\n", argv[0], argv[i] ); fprintf( stderr, "%s", im_error_buffer() ); im_error_clear(); } vips_shutdown(); return( 0 ); }
static void init_vips_library() { GOptionContext *context; GError *error = NULL; int i, argc; char **argv; VALUE argv_0, argv_v; argv_0 = rb_gv_get("0"); if (NIL_P(argv_0)) im_init_world(""); else im_init_world(RSTRING_PTR(argv_0)); argv_v = rb_const_get(rb_mKernel, rb_intern("ARGV")); if (!NIL_P(argv_v)) { argc = RARRAY_LEN(argv_v) + 1; argv = ALLOC_N(char*, argc); argv[0] = RSTRING_PTR(argv_0); for (i=0; i < argc - 1; i++) argv[i+1] = RSTRING_PTR(RARRAY_PTR(argv_v)[i]); context = g_option_context_new("- ruby-vips"); g_option_context_set_ignore_unknown_options(context, TRUE); g_option_context_add_group(context, im_get_option_group()); g_option_context_parse(context, &argc, &argv, &error); g_option_context_free(context); xfree(argv); }
int main( int argc, char **argv ) { GOptionContext *context; GError *error = NULL; IMAGE *im; unsigned char header[IM_SIZEOF_HEADER]; if( im_init_world( argv[0] ) ) error_exit( "%s", _( "unable to start VIPS" ) ); textdomain( GETTEXT_PACKAGE ); setlocale( LC_ALL, "" ); context = g_option_context_new( _( "vipsfile - edit vipsfile header" ) ); g_option_context_add_main_entries( context, entries, GETTEXT_PACKAGE ); g_option_context_add_group( context, im_get_option_group() ); if( !g_option_context_parse( context, &argc, &argv, &error ) ) { if( error ) { fprintf( stderr, "%s\n", error->message ); g_error_free( error ); } exit( -1 ); } if( argc != 2 ) { fprintf( stderr, _( "usage: %s [OPTION...] vipsfile\n" ), g_get_prgname() ); exit( -1 ); } if( !(im = im_init( argv[1] )) || (im->fd = im__open_image_file( im->filename )) == -1 ) error_exit( _( "could not open image %s" ), argv[1] ); if( read( im->fd, header, IM_SIZEOF_HEADER ) != IM_SIZEOF_HEADER || im__read_header_bytes( im, header ) ) error_exit( _( "could not read VIPS header for %s" ), im->filename ); if( xsize ) parse_pint( xsize, &im->Xsize ); if( ysize ) parse_pint( ysize, &im->Ysize ); if( bands ) parse_pint( bands, &im->Bands ); if( format ) { if( (im->BandFmt = im_char2BandFmt( format )) < 0 ) error_exit( _( "bad format %s" ), format ); im->Bbits = im_bits_of_fmt( im->BandFmt ); } if( type ) { if( (im->Type = im_char2Type( type )) < 0 ) error_exit( _( "bad type %s" ), type ); } if( coding ) { if( (im->Coding = im_char2Coding( coding )) < 0 ) error_exit( _( "bad coding %s" ), coding ); } if( xres ) im->Xres = atof( xres ); if( yres ) im->Yres = atof( yres ); if( xoffset ) im->Xoffset = atoi( xoffset ); if( yoffset ) im->Yoffset = atoi( yoffset ); if( lseek( im->fd, 0, SEEK_SET ) == (off_t) -1 ) error_exit( _( "could not seek on %s" ), im->filename ); if( im__write_header_bytes( im, header ) || im__write( im->fd, header, IM_SIZEOF_HEADER ) ) error_exit( _( "could not write to %s" ), im->filename ); if( setext ) { char *xml; unsigned int size; if( !(xml = im__file_read( stdin, "stdin", &size )) ) error_exit( "%s", _( "could not get ext data" ) ); /* Strip trailing whitespace ... we can get stray \n at the * end, eg. "echo | edvips --setext fred.v". */ while( size > 0 && isspace( xml[size - 1] ) ) size -= 1; if( im__write_extension_block( im, xml, size ) ) error_exit( "%s", _( "could not set extension" ) ); im_free( xml ); } im_close( im ); vips_shutdown(); return( 0 ); }