static int thumbnail3( IMAGE *in, IMAGE *out ) { int shrink; double residual; VipsInterpolate *interp; int result; shrink = calculate_shrink( in->Xsize, in->Ysize, &residual ); /* For images smaller than the thumbnail, we upscale with nearest * neighbor. Otherwise we makes thumbnails that look fuzzy and awful. */ if( !(interp = VIPS_INTERPOLATE( vips_object_new_from_string( g_type_class_ref( VIPS_TYPE_INTERPOLATE ), residual > 1.0 ? "nearest" : interpolator ) )) ) return( -1 ); if( verbose ) { printf( "integer shrink by %d\n", shrink ); printf( "residual scale by %g\n", residual ); printf( "%s interpolation\n", VIPS_OBJECT_GET_CLASS( interp )->nickname ); } result = shrink_factor( in, out, shrink, residual, interp ); g_object_unref( interp ); return( result ); }
/* Init function for input interpolate. */ static int input_interpolate_init( im_object *obj, char *str ) { VipsObjectClass *interpolate_class; VipsObject *object; interpolate_class = vips_class_find( "VipsInterpolate", "interpolate" ); if( !(object = vips_object_new_from_string( interpolate_class, str )) ) return( -1 ); *obj = object; return( 0 ); }
static VipsInterpolate * thumbnail_interpolator( VipsObject *process, VipsImage *in ) { double residual; VipsInterpolate *interp; calculate_shrink( in, &residual ); /* For images smaller than the thumbnail, we upscale with nearest * neighbor. Otherwise we makes thumbnails that look fuzzy and awful. */ if( !(interp = VIPS_INTERPOLATE( vips_object_new_from_string( g_type_class_ref( VIPS_TYPE_INTERPOLATE ), residual > 1.0 ? "nearest" : interpolator ) )) ) return( NULL ); vips_object_local( process, interp ); return( interp ); }