コード例 #1
0
ファイル: ruby_vips.c プロジェクト: ZeroPivot/ruby-vips
void
vips_lib_error()
{
    VALUE vips_error = rb_str_new2(im_error_buffer());
    im_error_clear();
    rb_raise(eVIPSError, "VIPS error: %s", RSTRING_PTR(vips_error));
}
コード例 #2
0
ファイル: header.c プロジェクト: anasazi/POP-REU-Project
/* A non-fatal error. Print the vips error buffer and continue.
 */
static void
print_error( const char *fmt, ... )
{
	va_list ap;

        va_start( ap, fmt );
        vfprintf( stderr, fmt, ap );
        va_end( ap );
        fprintf( stderr, "\n%s\n", im_error_buffer() );
	im_error_clear();
}
コード例 #3
0
ファイル: vipsobject.c プロジェクト: jcupitt/nip2
/* Make a VipsObject.
 */
void
vo_object_new( Reduce *rc, const char *name, 
	PElement *required, PElement *optional, PElement *out )
{
	Vo *vo;
	Managedgobject *managedgobject;

	if( !(vo = vo_new( rc, name )) ) 
		reduce_throw( rc );

	if( !vo_args( vo, required, optional ) ) {
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Ask the object to construct.
	 */
	if( vips_object_build( vo->object ) ) {
		error_top( _( "VIPS library error." ) );
		error_sub( "%s", im_error_buffer() );
		im_error_clear();
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Return the constructed object.
	 */
	if( !(managedgobject = managedgobject_new( vo->rc->heap, 
		G_OBJECT( vo->object ) )) ) {
		vo_free( vo );
		reduce_throw( rc );
	}

	PEPUTP( out, ELEMENT_MANAGED, managedgobject );

#ifdef DEBUG
{
	char txt[1000];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	vips_object_to_string( vo->object, &buf );
	printf( "vo_object_new: built %s\n", vips_buf_all( &buf ) );
}
#endif /*DEBUG*/

	vo_free( vo );
}
コード例 #4
0
ファイル: error.c プロジェクト: Ikulagin/transmem
/**
 * error_exit: 
 * @fmt: printf()-style format string for the message
 * @Varargs: arguments to the format string
 *
 * Sends a formatted error message to stderr, then sends the contents of the
 * error buffer, if any, then terminates the program with an error code.
 *
 * @fmt may be %NULL, in which case only the error buffer is printed before
 * exiting.
 *
 * See also: im_error().
 */
void 
error_exit( const char *fmt, ... )
{	
	if( fmt ) {
		va_list ap;

		fprintf( stderr, "%s: ", g_get_prgname() );

		va_start( ap, fmt );
		(void) vfprintf( stderr, fmt, ap );
		va_end( ap );

		fprintf( stderr, "\n" );
	}

	fprintf( stderr, "%s", im_error_buffer() );

	exit( 1 );
}
コード例 #5
0
ファイル: vipsthumbnail.c プロジェクト: ashishof77/libvips
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 );
}
コード例 #6
0
ファイル: vipsobject.c プロジェクト: jcupitt/nip2
/* Run a VipsOperation. Like vo_object_new(), but we return the output args
 * rather than the operation.
 */
void
vo_call( Reduce *rc, const char *name, 
	PElement *required, PElement *optional, PElement *out )
{
	Vo *vo;
	PElement pe;

	if( !(vo = vo_new( rc, name )) ) 
		reduce_throw( rc );

	if( !vo_args( vo, required, optional ) ) {
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Ask the object to construct. This can update vo->operation with an
	 * old one from the cache.
	 */
	if( vips_cache_operation_buildp( (VipsOperation **) &vo->object ) ) {
		error_top( _( "VIPS library error." ) );
		error_sub( "%s", im_error_buffer() );
		im_error_clear();
		vips_object_unref_outputs( vo->object );
		vo_free( vo );
		reduce_throw( rc );
	}

	/* We can't build the output object directly on out, since it might be
	 * one of our inputs. We use the safe Element in vo for the build,
	 * then copy at the end.
	 */

	/* Empty output list.
	 */
	PEPOINTE( &pe, &vo->out );
	heap_list_init( &pe );

	/* Append required outputs.
	 */
	if( vips_argument_map( VIPS_OBJECT( vo->object ),
		(VipsArgumentMapFn) vo_get_required_output, vo, &pe ) ) {
		vips_object_unref_outputs( vo->object );
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Append optional outputs.
	 */
	if( !vo_get_optional( vo, optional, &pe ) ) {
		vips_object_unref_outputs( vo->object );
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Now write the output object to out.
	 */
	PEPUTE( out, &vo->out );

	vips_object_unref_outputs( vo->object );
	vo_free( vo );
}
コード例 #7
0
ファイル: im_jpeg2vips.c プロジェクト: aturcotte/libvips
/* Read a JPEG file into a VIPS image.
 */
static int
jpeg2vips( const char *name, IMAGE *out, gboolean header_only )
{
	char filename[FILENAME_MAX];
	char mode[FILENAME_MAX];
	char *p, *q;
	int shrink;
	struct jpeg_decompress_struct cinfo;
        ErrorManager eman;
	FILE *fp;
	int result;
	gboolean invert_pels;
	gboolean fail_on_warn;

	/* By default, we ignore any warnings. We want to get as much of
	 * the user's data as we can.
	 */
	fail_on_warn = FALSE;

	/* Parse the filename.
	 */
	im_filename_split( name, filename, mode );
	p = &mode[0];
	shrink = 1;
	if( (q = im_getnextoption( &p )) ) {
		shrink = atoi( q );

		if( shrink != 1 && shrink != 2 && 
			shrink != 4 && shrink != 8 ) {
			im_error( "im_jpeg2vips", 
				_( "bad shrink factor %d" ), shrink );
			return( -1 );
		}
	}
	if( (q = im_getnextoption( &p )) ) {
		if( im_isprefix( "fail", q ) ) 
			fail_on_warn = TRUE;
	}

	/* Make jpeg dcompression object.
 	 */
        cinfo.err = jpeg_std_error( &eman.pub );
	eman.pub.error_exit = new_error_exit;
	eman.pub.output_message = new_output_message;
	eman.fp = NULL;
	if( setjmp( eman.jmp ) ) {
		/* Here for longjmp() from new_error_exit().
		 */
		jpeg_destroy_decompress( &cinfo );

		return( -1 );
	}
        jpeg_create_decompress( &cinfo );

	/* Make input.
	 */
        if( !(fp = im__file_open_read( filename, NULL, FALSE )) ) 
                return( -1 );
	eman.fp = fp;
        jpeg_stdio_src( &cinfo, fp );

	/* Need to read in APP1 (EXIF metadata) and APP2 (ICC profile).
	 */
	jpeg_save_markers( &cinfo, JPEG_APP0 + 1, 0xffff );
	jpeg_save_markers( &cinfo, JPEG_APP0 + 2, 0xffff );

	/* Convert!
	 */
	result = read_jpeg_header( &cinfo, out, &invert_pels, shrink );
	if( !header_only && !result )
		result = read_jpeg_image( &cinfo, out, invert_pels );

	/* Close and tidy.
	 */
	fclose( fp );
	eman.fp = NULL;
	jpeg_destroy_decompress( &cinfo );

	if( eman.pub.num_warnings != 0 ) {
		if( fail_on_warn ) {
			im_error( "im_jpeg2vips", "%s", im_error_buffer() );
			result = -1;
		}
		else {
			im_warn( "im_jpeg2vips", _( "read gave %ld warnings" ), 
				eman.pub.num_warnings );
			im_warn( "im_jpeg2vips", "%s", im_error_buffer() );
		}
	}

	return( result );
}
コード例 #8
0
ファイル: header.c プロジェクト: alon/libvips
/* A non-fatal error. Print the vips error buffer and continue.
 */
static void
print_error( void )
{
        fprintf( stderr, "%s: %s", g_get_prgname(), im_error_buffer() );
	im_error_clear();
}