Merge branch 'glib-logging'

This commit is contained in:
John Cupitt 2017-01-04 14:58:11 +00:00
commit c4640b61c7
46 changed files with 283 additions and 351 deletions

View File

@ -17,6 +17,7 @@
- added #defines for VIPS_SONAME, VIPS_LIBRARY_CURRENT, VIPS_LIBRARY_REVISION, - added #defines for VIPS_SONAME, VIPS_LIBRARY_CURRENT, VIPS_LIBRARY_REVISION,
VIPS_LIBRARY_AGE VIPS_LIBRARY_AGE
- better support for bscale / bzero in fits images - better support for bscale / bzero in fits images
- deprecate vips_warn() / vips_info(); use g_warning() / g_info() instead
8/12/16 started 8.4.5 8/12/16 started 8.4.5
- allow libgsf-1.14.26 to help centos, thanks tdiprima - allow libgsf-1.14.26 to help centos, thanks tdiprima

View File

@ -350,7 +350,7 @@ set_property( VipsObject *object, const char *name, const GValue *value )
if( vips_object_get_argument( object, name, if( vips_object_get_argument( object, name,
&pspec, &argument_class, &argument_instance ) ) { &pspec, &argument_class, &argument_instance ) ) {
vips_warn( NULL, "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
return; return;
} }
@ -364,7 +364,7 @@ set_property( VipsObject *object, const char *name, const GValue *value )
if( (enum_value = vips_enum_from_nick( object_class->nickname, if( (enum_value = vips_enum_from_nick( object_class->nickname,
pspec_type, g_value_get_string( value ) )) < 0 ) { pspec_type, g_value_get_string( value ) )) < 0 ) {
vips_warn( NULL, "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
return; return;
} }

View File

@ -208,6 +208,14 @@ rm t1.v
leak-test on exit, and also display an estimate of peak memory use. leak-test on exit, and also display an estimate of peak memory use.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
Set <code>G_MESSAGES_DEBUG=VIPS</code> and GLib will display
informational and debug messages from libvips.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</para> </para>

View File

@ -165,9 +165,11 @@ vips_measure_build( VipsObject *object )
*/ */
if( dev * 5 > VIPS_FABS( avg ) && if( dev * 5 > VIPS_FABS( avg ) &&
VIPS_FABS( avg ) > 3 ) VIPS_FABS( avg ) > 3 )
vips_warn( class->nickname, g_warning( _( "%s: "
_( "patch %d x %d, band %d: " "patch %d x %d, "
"avg = %g, sdev = %g" ), "band %d: "
"avg = %g, sdev = %g" ),
class->nickname,
i, j, b, avg, dev ); i, j, b, avg, dev );
*VIPS_MATRIX( measure->out, *VIPS_MATRIX( measure->out,

View File

@ -193,9 +193,9 @@ static int
icc_error( int code, const char *text ) icc_error( int code, const char *text )
{ {
if( code == LCMS_ERRC_WARNING ) if( code == LCMS_ERRC_WARNING )
vips_warn( "VipsIcc", "%s", text ); g_warning( "%s", text );
else else
vips_error( "VipsIcc", "%s", text ); vips_error( "VipsIcc", text );
return( 0 ); return( 0 );
} }
@ -452,9 +452,9 @@ vips_check_intent( const char *domain,
{ {
if( profile && if( profile &&
!cmsIsIntentSupported( profile, intent, direction ) ) !cmsIsIntentSupported( profile, intent, direction ) )
vips_warn( domain, g_warning( _( "%s: intent %d (%s) not supported by "
_( "intent %d (%s) not supported by "
"%s profile; falling back to default intent" ), "%s profile; falling back to default intent" ),
domain,
intent, vips_enum_nick( VIPS_TYPE_INTENT, intent ), intent, vips_enum_nick( VIPS_TYPE_INTENT, intent ),
direction == LCMS_USED_AS_INPUT ? direction == LCMS_USED_AS_INPUT ?
_( "input" ) : _( "output" ) ); _( "input" ) : _( "output" ) );
@ -542,7 +542,7 @@ vips_image_expected_bands( VipsImage *image )
} }
static cmsHPROFILE static cmsHPROFILE
vips_icc_load_profile_image( const char *domain, VipsImage *image ) vips_icc_load_profile_image( VipsImage *image )
{ {
void *data; void *data;
size_t data_length; size_t data_length;
@ -554,15 +554,15 @@ vips_icc_load_profile_image( const char *domain, VipsImage *image )
if( vips_image_get_blob( image, VIPS_META_ICC_NAME, if( vips_image_get_blob( image, VIPS_META_ICC_NAME,
&data, &data_length ) || &data, &data_length ) ||
!(profile = cmsOpenProfileFromMem( data, data_length )) ) { !(profile = cmsOpenProfileFromMem( data, data_length )) ) {
vips_warn( domain, "%s", _( "corrupt embedded profile" ) ); g_warning( "%s", _( "corrupt embedded profile" ) );
return( NULL ); return( NULL );
} }
if( vips_image_expected_bands( image ) != if( vips_image_expected_bands( image ) !=
vips_icc_profile_needs_bands( profile ) ) { vips_icc_profile_needs_bands( profile ) ) {
VIPS_FREEF( cmsCloseProfile, profile ); VIPS_FREEF( cmsCloseProfile, profile );
vips_warn( domain, g_warning( "%s",
"%s", _( "embedded profile incompatible with image" ) ); _( "embedded profile incompatible with image" ) );
return( NULL ); return( NULL );
} }
@ -584,8 +584,7 @@ vips_icc_load_profile_file( const char *domain,
if( vips_image_expected_bands( image ) != if( vips_image_expected_bands( image ) !=
vips_icc_profile_needs_bands( profile ) ) { vips_icc_profile_needs_bands( profile ) ) {
VIPS_FREEF( cmsCloseProfile, profile ); VIPS_FREEF( cmsCloseProfile, profile );
vips_warn( domain, g_warning( _( "profile \"%s\" incompatible with image" ),
_( "profile \"%s\" incompatible with image" ),
filename ); filename );
return( NULL ); return( NULL );
} }
@ -615,8 +614,7 @@ vips_icc_import_build( VipsObject *object )
if( code->in && if( code->in &&
(import->embedded || (import->embedded ||
!import->input_profile_filename) ) !import->input_profile_filename) )
icc->in_profile = vips_icc_load_profile_image( class->nickname, icc->in_profile = vips_icc_load_profile_image( code->in );
code->in );
if( !icc->in_profile && if( !icc->in_profile &&
code->in && code->in &&
@ -1027,8 +1025,7 @@ vips_icc_transform_build( VipsObject *object )
if( code->in && if( code->in &&
(transform->embedded || (transform->embedded ||
!transform->input_profile_filename) ) !transform->input_profile_filename) )
icc->in_profile = vips_icc_load_profile_image( class->nickname, icc->in_profile = vips_icc_load_profile_image( code->in );
code->in );
if( !icc->in_profile && if( !icc->in_profile &&
code->in && code->in &&

View File

@ -126,11 +126,9 @@ vips_cast_preeval( VipsImage *image, VipsProgress *progress, VipsCast *cast )
static void static void
vips_cast_posteval( VipsImage *image, VipsProgress *progress, VipsCast *cast ) vips_cast_posteval( VipsImage *image, VipsProgress *progress, VipsCast *cast )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( cast ); if( cast->overflow ||
cast->underflow )
if( cast->overflow || cast->underflow ) g_warning( _( "%d underflows and %d overflows detected" ),
vips_warn( class->nickname,
_( "%d underflows and %d overflows detected" ),
cast->underflow, cast->overflow ); cast->underflow, cast->overflow );
} }

View File

@ -177,7 +177,7 @@ vips_copy_build( VipsObject *object )
return( -1 ); return( -1 );
if( copy->swap ) if( copy->swap )
vips_warn( class->nickname, "%s", g_warning( "%s",
_( "copy swap is deprecated, use byteswap instead" ) ); _( "copy swap is deprecated, use byteswap instead" ) );
if( vips_image_pipelinev( conversion->out, if( vips_image_pipelinev( conversion->out,

View File

@ -124,7 +124,6 @@ vips_sequential_generate( VipsRegion *or,
void *seq, void *a, void *b, gboolean *stop ) void *seq, void *a, void *b, gboolean *stop )
{ {
VipsSequential *sequential = (VipsSequential *) b; VipsSequential *sequential = (VipsSequential *) b;
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( sequential );
VipsRect *r = &or->valid; VipsRect *r = &or->valid;
VipsRegion *ir = (VipsRegion *) seq; VipsRegion *ir = (VipsRegion *) seq;
@ -132,8 +131,7 @@ vips_sequential_generate( VipsRegion *or,
g_thread_self(), r->top, r->height ); g_thread_self(), r->top, r->height );
if( sequential->trace ) if( sequential->trace )
vips_info( class->nickname, g_info( "request for line %d, height %d",
"request for line %d, height %d",
r->top, r->height ); r->top, r->height );
VIPS_GATE_START( "vips_sequential_generate: wait" ); VIPS_GATE_START( "vips_sequential_generate: wait" );

View File

@ -605,7 +605,6 @@ vips_tile_cache_gen( VipsRegion *or,
{ {
VipsRegion *in = (VipsRegion *) seq; VipsRegion *in = (VipsRegion *) seq;
VipsBlockCache *cache = (VipsBlockCache *) b; VipsBlockCache *cache = (VipsBlockCache *) b;
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( cache );
VipsRect *r = &or->valid; VipsRect *r = &or->valid;
VipsTile *tile; VipsTile *tile;
@ -702,8 +701,7 @@ vips_tile_cache_gen( VipsRegion *or,
"vips_tile_cache_gen: " "vips_tile_cache_gen: "
"error on tile %p\n", tile ); "error on tile %p\n", tile );
vips_warn( class->nickname, g_warning( _( "error in tile %d x %d" ),
_( "error in tile %d x %d" ),
tile->pos.left, tile->pos.top ); tile->pos.left, tile->pos.top );
vips_region_black( tile->region ); vips_region_black( tile->region );

View File

@ -860,7 +860,7 @@ intize_to_fixed_point( VipsImage *in, int *out )
for( i = 0; i < ne; i++ ) for( i = 0; i < ne; i++ )
if( scaled[i] >= 4.0 || if( scaled[i] >= 4.0 ||
scaled[i] < -4 ) { scaled[i] < -4 ) {
vips_info( "intize_to_fixed_point", g_info( "intize_to_fixed_point: "
"out of range for vector path" ); "out of range for vector path" );
return( -1 ); return( -1 );
} }
@ -880,7 +880,7 @@ intize_to_fixed_point( VipsImage *in, int *out )
/* 0.1 is a 10% error. /* 0.1 is a 10% error.
*/ */
if( total_error > 0.1 ) { if( total_error > 0.1 ) {
vips_info( "intize_to_fixed_point", "too many underflows" ); g_info( "intize_to_fixed_point: too many underflows" );
return( -1 ); return( -1 );
} }
@ -906,7 +906,6 @@ intize_to_fixed_point( VipsImage *in, int *out )
static int static int
vips_convi_build( VipsObject *object ) vips_convi_build( VipsObject *object )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsConvolution *convolution = (VipsConvolution *) object; VipsConvolution *convolution = (VipsConvolution *) object;
VipsConvi *convi = (VipsConvi *) object; VipsConvi *convi = (VipsConvi *) object;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 );
@ -941,7 +940,7 @@ vips_convi_build( VipsObject *object )
!intize_to_fixed_point( M, convi->fixed ) && !intize_to_fixed_point( M, convi->fixed ) &&
!vips_convi_compile( convi, in ) ) { !vips_convi_compile( convi, in ) ) {
generate = vips_convi_gen_vector; generate = vips_convi_gen_vector;
vips_info( class->nickname, "using vector path" ); g_info( "using vector path" );
} }
else else
vips_convi_compile_free( convi ); vips_convi_compile_free( convi );
@ -980,7 +979,7 @@ vips_convi_build( VipsObject *object )
} }
generate = vips_convi_gen; generate = vips_convi_gen;
vips_info( class->nickname, "using C path" ); g_info( "using C path" );
} }
g_object_set( convi, "out", vips_image_new(), NULL ); g_object_set( convi, "out", vips_image_new(), NULL );

View File

@ -67,7 +67,6 @@ G_DEFINE_TYPE( VipsGaussblur, vips_gaussblur, VIPS_TYPE_OPERATION );
static int static int
vips_gaussblur_build( VipsObject *object ) vips_gaussblur_build( VipsObject *object )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsGaussblur *gaussblur = (VipsGaussblur *) object; VipsGaussblur *gaussblur = (VipsGaussblur *) object;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
@ -85,7 +84,7 @@ vips_gaussblur_build( VipsObject *object )
vips_matrixprint( t[0], NULL ); vips_matrixprint( t[0], NULL );
#endif /*DEBUG*/ #endif /*DEBUG*/
vips_info( class->nickname, "gaussblur mask width %d", t[0]->Xsize ); g_info( "gaussblur mask width %d", t[0]->Xsize );
if( vips_convsep( gaussblur->in, &t[1], t[0], if( vips_convsep( gaussblur->in, &t[1], t[0],
"precision", gaussblur->precision, "precision", gaussblur->precision,

View File

@ -724,3 +724,79 @@ vips_check_bands_3ormore( const char *domain, VipsImage *im )
{ {
return( vips_check_bands_atleast( domain, im, 3 ) ); return( vips_check_bands_atleast( domain, im, 3 ) );
} }
/* The old vips_info() stuff, now replaced by g_warning() / g_info().
*/
int vips__info = 0;
void
vips_info_set( gboolean info )
{
vips__info = info;
if( info ) {
const char *old;
char *new;
old = g_getenv( "G_MESSAGES_DEBUG" );
if( !old )
old = "";
new = g_strdup_printf( "%s VIPS", old );
g_setenv( "G_MESSAGES_DEBUG", new, TRUE );
g_free( new );
}
}
void
vips_vinfo( const char *domain, const char *fmt, va_list ap )
{
if( vips__info ) {
g_mutex_lock( vips__global_lock );
(void) fprintf( stderr, _( "%s: " ), _( "info" ) );
if( domain )
(void) fprintf( stderr, _( "%s: " ), domain );
(void) vfprintf( stderr, fmt, ap );
(void) fprintf( stderr, "\n" );
g_mutex_unlock( vips__global_lock );
}
}
void
vips_info( const char *domain, const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
vips_vinfo( domain, fmt, ap );
va_end( ap );
}
void
vips_vwarn( const char *domain, const char *fmt, va_list ap )
{
if( !g_getenv( "IM_WARNING" ) &&
!g_getenv( "VIPS_WARNING" ) ) {
g_mutex_lock( vips__global_lock );
(void) fprintf( stderr, _( "%s: " ), _( "vips warning" ) );
if( domain )
(void) fprintf( stderr, _( "%s: " ), domain );
(void) vfprintf( stderr, fmt, ap );
(void) fprintf( stderr, "\n" );
g_mutex_unlock( vips__global_lock );
}
if( vips__fatal )
vips_error_exit( "vips__fatal" );
}
void
vips_warn( const char *domain, const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
vips_vwarn( domain, fmt, ap );
va_end( ap );
}

View File

@ -195,8 +195,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256],
/* Only a warning, since (for example) exported spreadsheets /* Only a warning, since (for example) exported spreadsheets
* will often have text or date fields. * will often have text or date fields.
*/ */
vips_warn( "csv2vips", g_warning( _( "error parsing number, line %d, column %d" ),
_( "error parsing number, line %d, column %d" ),
lineno, colno ); lineno, colno );
if( fail ) if( fail )
return( EOF ); return( EOF );

View File

@ -1997,8 +1997,7 @@ vips_foreign_save_dz_build( VipsObject *object )
#ifndef HAVE_GSF_DEFLATE_LEVEL #ifndef HAVE_GSF_DEFLATE_LEVEL
if( dz->compression > 0 ) { if( dz->compression > 0 ) {
vips_warn( class->nickname, "%s", g_warning( _( "deflate-level not supported by libgsf, "
_( "deflate-level not supported by libgsf, "
"using default compression" ) ); "using default compression" ) );
dz->compression = -1; dz->compression = -1;
} }

View File

@ -846,9 +846,9 @@ vips_foreign_load_build( VipsObject *object )
if( (flags & VIPS_FOREIGN_PARTIAL) && if( (flags & VIPS_FOREIGN_PARTIAL) &&
(flags & VIPS_FOREIGN_SEQUENTIAL) ) { (flags & VIPS_FOREIGN_SEQUENTIAL) ) {
vips_warn( class->nickname, "%s", g_warning( "%s",
_( "VIPS_FOREIGN_PARTIAL and VIPS_FOREIGN_SEQUENTIAL " _( "VIPS_FOREIGN_PARTIAL and VIPS_FOREIGN_SEQUENTIAL "
"both set -- using SEQUENTIAL" ) ); "both set -- using SEQUENTIAL" ) );
flags ^= VIPS_FOREIGN_PARTIAL; flags ^= VIPS_FOREIGN_PARTIAL;
} }
@ -865,12 +865,10 @@ vips_foreign_load_build( VipsObject *object )
build( object ) ) build( object ) )
return( -1 ); return( -1 );
if( load->sequential ) { if( load->sequential )
vips_warn( class->nickname, "%s", g_warning( "%s",
_( "ignoring deprecated \"sequential\" mode" ) ); _( "ignoring deprecated \"sequential\" mode -- "
vips_warn( class->nickname, "%s", "please use \"access\" instead" ) );
_( "please use \"access\" instead" ) );
}
g_object_set( object, "out", vips_image_new(), NULL ); g_object_set( object, "out", vips_image_new(), NULL );

View File

@ -359,7 +359,6 @@ static void
vips_foreign_load_gif_render_line( VipsForeignLoadGif *gif, vips_foreign_load_gif_render_line( VipsForeignLoadGif *gif,
int width, VipsPel * restrict q, VipsPel * restrict p ) int width, VipsPel * restrict q, VipsPel * restrict p )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif );
ColorMapObject *map = gif->file->Image.ColorMap ? ColorMapObject *map = gif->file->Image.ColorMap ?
gif->file->Image.ColorMap : gif->file->SColorMap; gif->file->Image.ColorMap : gif->file->SColorMap;
@ -369,8 +368,7 @@ vips_foreign_load_gif_render_line( VipsForeignLoadGif *gif,
VipsPel v = p[x]; VipsPel v = p[x];
if( v >= map->ColorCount ) { if( v >= map->ColorCount ) {
vips_warn( class->nickname, g_warning( "%s", _( "pixel value out of range" ) );
"%s", _( "pixel value out of range" ) );
continue; continue;
} }

View File

@ -194,10 +194,9 @@ readjpeg_free( ReadJpeg *jpeg )
result = 0; result = 0;
if( jpeg->eman.pub.num_warnings != 0 ) { if( jpeg->eman.pub.num_warnings != 0 ) {
vips_warn( "VipsJpeg", g_warning( _( "read gave %ld warnings" ),
_( "read gave %ld warnings" ),
jpeg->eman.pub.num_warnings ); jpeg->eman.pub.num_warnings );
vips_warn( NULL, "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
/* Make the message only appear once. /* Make the message only appear once.
*/ */
@ -615,8 +614,7 @@ res_from_exif( VipsImage *im, ExifData *ed )
break; break;
default: default:
vips_warn( "VipsJpeg", g_warning( "%s", _( "unknown EXIF resolution unit" ) );
"%s", _( "unknown EXIF resolution unit" ) );
return( -1 ); return( -1 );
} }
@ -830,8 +828,7 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
break; break;
default: default:
vips_warn( "VipsJpeg", g_warning( "%s", _( "unknown JFIF resolution unit" ) );
"%s", _( "unknown JFIF resolution unit" ) );
break; break;
} }

View File

@ -799,9 +799,8 @@ vips__ppm_save( VipsImage *in, const char *filename,
if( ascii && if( ascii &&
in->BandFmt == VIPS_FORMAT_FLOAT ) { in->BandFmt == VIPS_FORMAT_FLOAT ) {
vips_warn( "vips2ppm", g_warning( "%s",
"%s", _( "float images must be binary -- " _( "float images must be binary -- disabling ascii" ) );
"disabling ascii" ) );
ascii = FALSE; ascii = FALSE;
} }
@ -810,8 +809,8 @@ vips__ppm_save( VipsImage *in, const char *filename,
if( squash && if( squash &&
(in->Bands != 1 || (in->Bands != 1 ||
in->BandFmt != VIPS_FORMAT_UCHAR) ) { in->BandFmt != VIPS_FORMAT_UCHAR) ) {
vips_warn( "vips2ppm", g_warning( "%s",
"%s", _( "can only squash 1 band uchar images -- " _( "can only squash 1 band uchar images -- "
"disabling squash" ) ); "disabling squash" ) );
squash = FALSE; squash = FALSE;
} }

View File

@ -58,8 +58,7 @@
#include "tiff.h" #include "tiff.h"
/* Handle TIFF errors here. Shared with vips2tiff.c. These can be called from /* Handle TIFF errors here. Shared with vips2tiff.c. These can be called from
* more than one thread, but vips_error and vips_warn have mutexes in, so that's * more than one thread.
* OK.
*/ */
static void static void
vips__thandler_error( const char *module, const char *fmt, va_list ap ) vips__thandler_error( const char *module, const char *fmt, va_list ap )
@ -73,10 +72,7 @@ vips__thandler_error( const char *module, const char *fmt, va_list ap )
static void static void
vips__thandler_warning( const char *module, const char *fmt, va_list ap ) vips__thandler_warning( const char *module, const char *fmt, va_list ap )
{ {
char buf[256]; g_logv( G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, fmt, ap );
vips_vsnprintf( buf, 256, fmt, ap );
vips_warn( module, "%s", buf );
} }
/* Call this during startup. Other libraries may be using libtiff and we want /* Call this during startup. Other libraries may be using libtiff and we want

View File

@ -387,7 +387,7 @@ get_resolution( TIFF *tiff, VipsImage *out )
} }
} }
else { else {
vips_warn( "tiff2vips", _( "no resolution information for " g_warning( _( "no resolution information for "
"TIFF image \"%s\" -- defaulting to 1 pixel per mm" ), "TIFF image \"%s\" -- defaulting to 1 pixel per mm" ),
TIFFFileName( tiff ) ); TIFFFileName( tiff ) );
x = 1.0; x = 1.0;
@ -1041,7 +1041,7 @@ rtiff_parse_palette( Rtiff *rtiff, VipsImage *out )
read->blue8[i] = read->blue16[i] >> 8; read->blue8[i] = read->blue16[i] >> 8;
} }
else { else {
vips_warn( "tiff2vips", "%s", _( "assuming 8-bit palette" ) ); g_warning( "%s", _( "assuming 8-bit palette" ) );
for( i = 0; i < len; i++ ) { for( i = 0; i < len; i++ ) {
read->red8[i] = read->red16[i] & 0xff; read->red8[i] = read->red16[i] & 0xff;

View File

@ -495,8 +495,7 @@ vips__set_exif_resolution( ExifData *ed, VipsImage *im )
break; break;
default: default:
vips_warn( "VipsJpeg", g_warning( "%s", _( "unknown EXIF resolution unit" ) );
"%s", _( "unknown EXIF resolution unit" ) );
return( 0 ); return( 0 );
} }
@ -626,7 +625,7 @@ vips_exif_image_field( VipsImage *image,
/* value must be a string. /* value must be a string.
*/ */
if( vips_image_get_string( image, field, &string ) ) { if( vips_image_get_string( image, field, &string ) ) {
vips_warn( "VipsJpeg", _( "bad exif meta \"%s\"" ), field ); g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL ); return( NULL );
} }
@ -636,12 +635,12 @@ vips_exif_image_field( VipsImage *image,
for( ; isdigit( *p ); p++ ) for( ; isdigit( *p ); p++ )
; ;
if( *p != '-' ) { if( *p != '-' ) {
vips_warn( "VipsJpeg", _( "bad exif meta \"%s\"" ), field ); g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL ); return( NULL );
} }
if( !(tag = exif_tag_from_name( p + 1 )) ) { if( !(tag = exif_tag_from_name( p + 1 )) ) {
vips_warn( "VipsJpeg", _( "bad exif meta \"%s\"" ), field ); g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL ); return( NULL );
} }
@ -764,7 +763,7 @@ write_blob( Write *write, const char *field, int app )
* For now, just ignore oversize objects and warn. * For now, just ignore oversize objects and warn.
*/ */
if( data_length > 65530 ) if( data_length > 65530 )
vips_warn( "VipsJpeg", _( "field \"%s\" is too large " g_warning( _( "field \"%s\" is too large "
"for a single JPEG marker, ignoring" ), "for a single JPEG marker, ignoring" ),
field ); field );
else { else {
@ -1082,8 +1081,7 @@ write_vips( Write *write, int qfac, const char *profile,
write->cinfo.optimize_coding = TRUE; write->cinfo.optimize_coding = TRUE;
} }
else else
vips_warn( "vips2jpeg", g_warning( "%s", _( "trellis_quant unsupported" ) );
"%s", _( "trellis_quant unsupported" ) );
} }
/* Apply overshooting to samples with extreme values e.g. 0 & 255 /* Apply overshooting to samples with extreme values e.g. 0 & 255
@ -1095,8 +1093,8 @@ write_vips( Write *write, int qfac, const char *profile,
jpeg_c_set_bool_param( &write->cinfo, jpeg_c_set_bool_param( &write->cinfo,
JBOOLEAN_OVERSHOOT_DERINGING, TRUE ); JBOOLEAN_OVERSHOOT_DERINGING, TRUE );
else else
vips_warn( "vips2jpeg", g_warning( "%s",
"%s", _( "overshoot_deringing unsupported" ) ); _( "overshoot_deringing unsupported" ) );
} }
/* Split the spectrum of DCT coefficients into separate scans. /* Split the spectrum of DCT coefficients into separate scans.
* Requires progressive output. Must be set before * Requires progressive output. Must be set before
@ -1109,12 +1107,12 @@ write_vips( Write *write, int qfac, const char *profile,
jpeg_c_set_bool_param( &write->cinfo, jpeg_c_set_bool_param( &write->cinfo,
JBOOLEAN_OPTIMIZE_SCANS, TRUE ); JBOOLEAN_OPTIMIZE_SCANS, TRUE );
else else
vips_warn( "vips2jpeg", g_warning( "%s",
"%s", _( "Ignoring optimize_scans" ) ); _( "ignoring optimize_scans" ) );
} }
else else
vips_warn( "vips2jpeg", "%s", g_warning( "%s",
_( "Ignoring optimize_scans for baseline" ) ); _( "ignoring optimize_scans for baseline" ) );
} }
/* Use predefined quantization table. /* Use predefined quantization table.
@ -1125,22 +1123,21 @@ write_vips( Write *write, int qfac, const char *profile,
jpeg_c_set_int_param( &write->cinfo, jpeg_c_set_int_param( &write->cinfo,
JINT_BASE_QUANT_TBL_IDX, quant_table ); JINT_BASE_QUANT_TBL_IDX, quant_table );
else else
vips_warn( "vips2jpeg", g_warning( "%s",
"%s", _( "Setting quant_table unsupported" ) ); _( "setting quant_table unsupported" ) );
} }
#else #else
/* Using jpeglib.h without extension parameters, warn of ignored /* Using jpeglib.h without extension parameters, warn of ignored
* options. * options.
*/ */
if( trellis_quant ) if( trellis_quant )
vips_warn( "vips2jpeg", "%s", _( "Ignoring trellis_quant" ) ); g_warning( "%s", _( "ignoring trellis_quant" ) );
if( overshoot_deringing ) if( overshoot_deringing )
vips_warn( "vips2jpeg", g_warning( "%s", _( "ignoring overshoot_deringing" ) );
"%s", _( "Ignoring overshoot_deringing" ) );
if( optimize_scans ) if( optimize_scans )
vips_warn( "vips2jpeg", "%s", _( "Ignoring optimize_scans" ) ); g_warning( "%s", _( "ignoring optimize_scans" ) );
if( quant_table > 0 ) if( quant_table > 0 )
vips_warn( "vips2jpeg", "%s", _( "Ignoring quant_table" ) ); g_warning( "%s", _( "ignoring quant_table" ) );
#endif #endif
/* Set compression quality. Must be called after setting params above. /* Set compression quality. Must be called after setting params above.

View File

@ -464,8 +464,7 @@ wtiff_embed_ipct( Wtiff *wtiff, TIFF *tif )
* long, not byte. * long, not byte.
*/ */
if( data_length & 3 ) { if( data_length & 3 ) {
vips_warn( "vips2tiff", g_warning( "%s", _( "rounding up IPCT data length" ) );
"%s", _( "rounding up IPCT data length" ) );
data_length /= 4; data_length /= 4;
data_length += 1; data_length += 1;
} }
@ -958,8 +957,8 @@ wtiff_new( VipsImage *im, const char *filename,
/* We can't pyramid toilet roll images. /* We can't pyramid toilet roll images.
*/ */
if( wtiff->pyramid ) { if( wtiff->pyramid ) {
vips_warn( "vips2tiff", g_warning( "%s",
"%s", _( "can't pyramid multi page images --- " _( "can't pyramid multi page images --- "
"disabling pyramid" ) ); "disabling pyramid" ) );
wtiff->pyramid = FALSE; wtiff->pyramid = FALSE;
} }
@ -995,16 +994,16 @@ wtiff_new( VipsImage *im, const char *filename,
(im->Coding != VIPS_CODING_NONE || (im->Coding != VIPS_CODING_NONE ||
im->BandFmt != VIPS_FORMAT_UCHAR || im->BandFmt != VIPS_FORMAT_UCHAR ||
im->Bands != 1) ) { im->Bands != 1) ) {
vips_warn( "vips2tiff", g_warning( "%s",
"%s", _( "can only squash 1 band uchar images -- " _( "can only squash 1 band uchar images -- "
"disabling squash" ) ); "disabling squash" ) );
wtiff->onebit = 0; wtiff->onebit = 0;
} }
if( wtiff->onebit && if( wtiff->onebit &&
wtiff->compression == COMPRESSION_JPEG ) { wtiff->compression == COMPRESSION_JPEG ) {
vips_warn( "vips2tiff", g_warning( "%s",
"%s", _( "can't have 1-bit JPEG -- disabling JPEG" ) ); _( "can't have 1-bit JPEG -- disabling JPEG" ) );
wtiff->compression = COMPRESSION_NONE; wtiff->compression = COMPRESSION_NONE;
} }
@ -1014,8 +1013,8 @@ wtiff_new( VipsImage *im, const char *filename,
(im->Coding != VIPS_CODING_NONE || (im->Coding != VIPS_CODING_NONE ||
vips_band_format_iscomplex( im->BandFmt ) || vips_band_format_iscomplex( im->BandFmt ) ||
im->Bands > 2) ) { im->Bands > 2) ) {
vips_warn( "vips2tiff", g_warning( "%s",
"%s", _( "can only save non-complex greyscale images " _( "can only save non-complex greyscale images "
"as miniswhite -- disabling miniswhite" ) ); "as miniswhite -- disabling miniswhite" ) );
wtiff->miniswhite = FALSE; wtiff->miniswhite = FALSE;
} }

View File

@ -161,11 +161,9 @@ write_webp( WebPPicture *pic, VipsImage *in,
pic->use_argb = lossless || near_lossless || smart_subsample; pic->use_argb = lossless || near_lossless || smart_subsample;
#else #else
if( lossless || near_lossless ) if( lossless || near_lossless )
vips_warn( "vips2webp", g_warning( "%s", _( "lossless unsupported" ) );
"%s", _( "lossless unsupported" ) );
if( alpha_q != 100 ) if( alpha_q != 100 )
vips_warn( "vips2webp", g_warning( "%s", _( "alpha_q unsupported" ) );
"%s", _( "alpha_q unsupported" ) );
#endif #endif
#if WEBP_ENCODER_ABI_VERSION >= 0x0209 #if WEBP_ENCODER_ABI_VERSION >= 0x0209
@ -175,11 +173,9 @@ write_webp( WebPPicture *pic, VipsImage *in,
config.preprocessing |= 4; config.preprocessing |= 4;
#else #else
if( near_lossless ) if( near_lossless )
vips_warn( "vips2webp", g_warning( "%s", _( "near_lossless unsupported" ) );
"%s", _( "near_lossless unsupported" ) );
if( smart_subsample ) if( smart_subsample )
vips_warn( "vips2webp", g_warning( "%s", _( "smart_subsample unsupported" ) );
"%s", _( "smart_subsample unsupported" ) );
#endif #endif
if( !WebPValidateConfig( &config ) ) { if( !WebPValidateConfig( &config ) ) {

View File

@ -106,11 +106,8 @@ static void
vips_maplut_posteval( VipsImage *image, VipsProgress *progress, vips_maplut_posteval( VipsImage *image, VipsProgress *progress,
VipsMaplut *maplut ) VipsMaplut *maplut )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( maplut );
if( maplut->overflow ) if( maplut->overflow )
vips_warn( class->nickname, g_warning( _( "%d overflows detected" ), maplut->overflow );
_( "%d overflows detected" ), maplut->overflow );
} }
/* Our sequence value: the region this sequence is using, and local stats. /* Our sequence value: the region this sequence is using, and local stats.

View File

@ -284,6 +284,14 @@ int im_plotpoint( IMAGE *im, int x, int y, PEL *pel );
int im_smudge( IMAGE *image, int ix, int iy, VipsRect *r ); int im_smudge( IMAGE *image, int ix, int iy, VipsRect *r );
int im_smear( IMAGE *im, int ix, int iy, VipsRect *r ); int im_smear( IMAGE *im, int ix, int iy, VipsRect *r );
void vips_warn( const char *domain, const char *fmt, ... )
__attribute__((format(printf, 2, 3)));
void vips_vwarn( const char *domain, const char *fmt, va_list ap );
void vips_info_set( gboolean info );
void vips_info( const char *domain, const char *fmt, ... )
__attribute__((format(printf, 2, 3)));
void vips_vinfo( const char *domain, const char *fmt, va_list ap );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /*__cplusplus*/ #endif /*__cplusplus*/

View File

@ -50,13 +50,6 @@ void vips_verror_system( int err, const char *domain,
const char *fmt, va_list ap ); const char *fmt, va_list ap );
void vips_error_g( GError **error ); void vips_error_g( GError **error );
void vips_g_error( GError **error ); void vips_g_error( GError **error );
void vips_warn( const char *domain, const char *fmt, ... )
__attribute__((format(printf, 2, 3)));
void vips_vwarn( const char *domain, const char *fmt, va_list ap );
void vips_info_set( gboolean info );
void vips_info( const char *domain, const char *fmt, ... )
__attribute__((format(printf, 2, 3)));
void vips_vinfo( const char *domain, const char *fmt, va_list ap );
void vips_error_exit( const char *fmt, ... ) void vips_error_exit( const char *fmt, ... )
__attribute__((noreturn, format(printf, 1, 2))); __attribute__((noreturn, format(printf, 1, 2)));

View File

@ -135,6 +135,15 @@ G_STMT_START { \
} \ } \
} G_STMT_END } G_STMT_END
/* The g_info() macro was added in 2.40.
*/
#ifndef g_info
/* Hopefully we have varargs macros. Maybe revisit this.
*/
#define g_info(...) \
g_log( G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__ )
#endif
/* Various integer range clips. Record over/under flows. /* Various integer range clips. Record over/under flows.
*/ */
#define VIPS_CLIP_UCHAR( V, SEQ ) \ #define VIPS_CLIP_UCHAR( V, SEQ ) \

View File

@ -166,12 +166,10 @@ extern "C" {
#define VIPS_INIT( ARGV0 ) \ #define VIPS_INIT( ARGV0 ) \
(vips_version( 3 ) - vips_version( 5 ) != \ (vips_version( 3 ) - vips_version( 5 ) != \
VIPS_LIBRARY_CURRENT - VIPS_LIBRARY_AGE ? ( \ VIPS_LIBRARY_CURRENT - VIPS_LIBRARY_AGE ? ( \
vips_info( "vips_init", "ABI mismatch" ), \ g_warning( "ABI mismatch" ), \
vips_info( "vips_init", \ g_warning( "library has ABI version %d", \
"library has ABI version %d", \
vips_version( 3 ) - vips_version( 5 ) ), \ vips_version( 3 ) - vips_version( 5 ) ), \
vips_info( "vips_init", \ g_warning( "application needs ABI version %d", \
"application needs ABI version %d", \
VIPS_LIBRARY_CURRENT - VIPS_LIBRARY_AGE ), \ VIPS_LIBRARY_CURRENT - VIPS_LIBRARY_AGE ), \
vips_error( "vips_init", "ABI mismatch" ), \ vips_error( "vips_init", "ABI mismatch" ), \
-1 ) : \ -1 ) : \

View File

@ -103,12 +103,29 @@
* *
* The domain argument most of these functions take is not localised and is * The domain argument most of these functions take is not localised and is
* supposed to indicate the component which failed. * supposed to indicate the component which failed.
*
* libvips uses g_warning() and g_info() to send warning and information
* messages to the user. You can use the usual glib mechanisms to display or
* divert these messages. For example, info messages are hidden by default, but
* you can see them with:
*
* |[
* $ G_MESSAGES_DEBUG=VIPS vipsthumbnail k2.jpg
* VIPS-INFO: thumbnailing k2.jpg
* VIPS-INFO: selected loader is VipsForeignLoadJpegFile
* VIPS-INFO: input size is 1450 x 2048
* VIPS-INFO: loading jpeg with factor 8 pre-shrink
* VIPS-INFO: converting to processing space srgb
* VIPS-INFO: residual reducev by 0.5
* VIPS-INFO: 13 point mask
* VIPS-INFO: using vector path
* VIPS-INFO: residual reduceh by 0.5
* VIPS-INFO: 13 point mask
* VIPS-INFO: thumbnailing k2.jpg as ./tn_k2.jpg
* ]|
*
*/ */
/* Show info messages. Handy for debugging.
*/
int vips__info = 0;
/* Make global array to keep the error message buffer. /* Make global array to keep the error message buffer.
*/ */
#define VIPS_MAX_ERROR (10240) #define VIPS_MAX_ERROR (10240)
@ -371,125 +388,6 @@ vips_error_clear( void )
g_mutex_unlock( vips__global_lock ); g_mutex_unlock( vips__global_lock );
} }
/**
* vips_info_set:
* @info: %TRUE to enable info messages
*
* If set, vips will output various informative messages to stderr as it works.
*
* See also: vips_info().
*/
void
vips_info_set( gboolean info )
{
vips__info = info;
}
/**
* vips_vinfo:
* @domain: the source of the message
* @fmt: printf()-style format string for the message
* @ap: arguments to the format string
*
* Sends a formatted informational message to stderr if the --vips-info flag
* has been given to the program, or the environment variable VIPS_INFO has been
* defined, or if vips_info_set() has been called.
*
* Informational messages are used to report details about the operation of
* functions.
*
* See also: vips_info(), vips_info_set(), vips_warn().
*/
void
vips_vinfo( const char *domain, const char *fmt, va_list ap )
{
if( vips__info ) {
g_mutex_lock( vips__global_lock );
(void) fprintf( stderr, _( "%s: " ), _( "info" ) );
if( domain )
(void) fprintf( stderr, _( "%s: " ), domain );
(void) vfprintf( stderr, fmt, ap );
(void) fprintf( stderr, "\n" );
g_mutex_unlock( vips__global_lock );
}
}
/**
* vips_info:
* @domain: the source of the diagnostic message
* @fmt: printf()-style format string for the message
* @...: arguments to the format string
*
* Sends a formatted informational message to stderr if the --vips-info flag
* has been given to the program or the environment variable VIPS_INFO has been
* defined, or if vips_info_set() has been called.
*
* Informational messages are used to report details about the operation of
* functions.
*
* See also: vips_info_set(), vips_vinfo(), vips_warn().
*/
void
vips_info( const char *domain, const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
vips_vinfo( domain, fmt, ap );
va_end( ap );
}
/**
* vips_vwarn:
* @domain: the source of the warning message
* @fmt: printf()-style format string for the message
* @ap: arguments to the format string
*
* Exactly as vips_warn(), but takes a va_list argument.
*
* See also: vips_warn().
*/
void
vips_vwarn( const char *domain, const char *fmt, va_list ap )
{
if( !g_getenv( "IM_WARNING" ) &&
!g_getenv( "VIPS_WARNING" ) ) {
g_mutex_lock( vips__global_lock );
(void) fprintf( stderr, _( "%s: " ), _( "vips warning" ) );
if( domain )
(void) fprintf( stderr, _( "%s: " ), domain );
(void) vfprintf( stderr, fmt, ap );
(void) fprintf( stderr, "\n" );
g_mutex_unlock( vips__global_lock );
}
if( vips__fatal )
vips_error_exit( "vips__fatal" );
}
/**
* vips_warn:
* @domain: the source of the warning message
* @fmt: printf()-style format string for the message
* @...: arguments to the format string
*
* Sends a formatted warning message to stderr. If you define the
* environment variable VIPS_WARNING, these message are supressed.
*
* Warning messages are used to report things like overflow counts.
*
* See also: vips_info(), vips_vwarn().
*/
void
vips_warn( const char *domain, const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
vips_vwarn( domain, fmt, ap );
va_end( ap );
}
/** /**
* vips_error_exit: * vips_error_exit:
* @fmt: printf()-style format string for the message * @fmt: printf()-style format string for the message

View File

@ -143,8 +143,7 @@ vips_thread_profile_save( VipsThreadProfile *profile )
vips__file_open_write( "vips-profile.txt", TRUE ); vips__file_open_write( "vips-profile.txt", TRUE );
if( !vips__thread_fp ) { if( !vips__thread_fp ) {
g_mutex_unlock( vips__global_lock ); g_mutex_unlock( vips__global_lock );
vips_warn( "VipsGate", g_warning( "unable to create profile log" );
"%s", "unable to create profile log" );
return; return;
} }
@ -204,8 +203,7 @@ vips__thread_profile_init_cb( VipsThreadProfile *profile )
* been called. * been called.
*/ */
if( vips__thread_profile ) if( vips__thread_profile )
vips_warn( "VipsGate", g_warning( "discarding unsaved state for thread %p --- "
"discarding unsaved state for thread %p --- "
"call vips_thread_shutdown() for this thread", "call vips_thread_shutdown() for this thread",
profile->thread ); profile->thread );

View File

@ -411,7 +411,7 @@ vips_image_pipelinev( VipsImage *image, VipsDemandStyle hint, ... )
; ;
va_end( ap ); va_end( ap );
if( i == MAX_IMAGES ) { if( i == MAX_IMAGES ) {
vips_warn( "vips_image_pipeline", "%s", _( "too many images" ) ); g_warning( "%s", _( "too many images" ) );
/* Make sure we have a sentinel there. /* Make sure we have a sentinel there.
*/ */

View File

@ -1006,8 +1006,7 @@ vips_image_build( VipsObject *object )
* still be able to process it without coredumps. * still be able to process it without coredumps.
*/ */
if( image->file_length > sizeof_image ) if( image->file_length > sizeof_image )
vips_warn( "VipsImage", g_warning( _( "%s is longer than expected" ),
_( "%s is longer than expected" ),
image->filename ); image->filename );
break; break;
@ -2590,9 +2589,8 @@ vips_image_write_to_memory( VipsImage *in, size_t *size_out )
vips_error( "vips_image_write_to_memory", vips_error( "vips_image_write_to_memory",
_( "out of memory --- size == %dMB" ), _( "out of memory --- size == %dMB" ),
(int) (size / (1024.0 * 1024.0)) ); (int) (size / (1024.0 * 1024.0)) );
vips_warn( "vips_image_write_to_memory", g_warning( _( "out of memory --- size == %dMB" ),
_( "out of memory --- size == %dMB" ), (int) (size / (1024.0 * 1024.0)) );
(int) (size / (1024.0*1024.0)) );
return( NULL ); return( NULL );
} }
@ -3143,8 +3141,7 @@ vips_image_wio_input( VipsImage *image )
* generate from this image. * generate from this image.
*/ */
if( image->regions ) if( image->regions )
vips_warn( "vips_image_wio_input", "%s", g_warning( "rewinding image with active regions" );
"rewinding image with active regions" );
break; break;

View File

@ -226,10 +226,8 @@ vips_load_plugins( const char *fmt, ... )
module = g_module_open( path, G_MODULE_BIND_LAZY ); module = g_module_open( path, G_MODULE_BIND_LAZY );
if( !module ) { if( !module ) {
vips_warn( "vips_init", g_warning( _( "unable to load \"%s\" -- %s" ),
_( "unable to load \"%s\" -- %s" ), path, g_module_error() );
path,
g_module_error() );
result = -1; result = -1;
} }
} }
@ -343,11 +341,14 @@ vips_init( const char *argv0 )
bindtextdomain( GETTEXT_PACKAGE, name ); bindtextdomain( GETTEXT_PACKAGE, name );
bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" );
/* Default various settings from env. /* Deprecated, this is just for compat.
*/ */
if( g_getenv( "VIPS_INFO" ) || if( g_getenv( "VIPS_INFO" ) ||
g_getenv( "IM_INFO" ) ) g_getenv( "IM_INFO" ) )
vips_info_set( TRUE ); vips_info_set( TRUE );
/* Default various settings from env.
*/
if( g_getenv( "VIPS_TRACE" ) ) if( g_getenv( "VIPS_TRACE" ) )
vips_cache_set_trace( TRUE ); vips_cache_set_trace( TRUE );
@ -391,7 +392,7 @@ vips_init( const char *argv0 )
*/ */
if( im_load_plugins( "%s/vips-%d.%d", if( im_load_plugins( "%s/vips-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ) ) { libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ) ) {
vips_warn( "vips_init", "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
} }
@ -399,7 +400,7 @@ vips_init( const char *argv0 )
* :-( kept for back compat convenience. * :-( kept for back compat convenience.
*/ */
if( im_load_plugins( "%s", libdir ) ) { if( im_load_plugins( "%s", libdir ) ) {
vips_warn( "vips_init", "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
} }
@ -578,12 +579,12 @@ vips__ngettext( const char *msgid, const char *plural, unsigned long int n )
} }
static gboolean static gboolean
vips_lib_version_cb( const gchar *option_name, const gchar *value, vips_lib_info_cb( const gchar *option_name, const gchar *value,
gpointer data, GError **error ) gpointer data, GError **error )
{ {
printf( "libvips %s\n", VIPS_VERSION_STRING ); vips_info_set( TRUE );
vips_shutdown();
exit( 0 ); return( TRUE );
} }
static gboolean static gboolean
@ -604,9 +605,18 @@ vips_set_fatal_cb( const gchar *option_name, const gchar *value,
return( TRUE ); return( TRUE );
} }
static gboolean
vips_lib_version_cb( const gchar *option_name, const gchar *value,
gpointer data, GError **error )
{
printf( "libvips %s\n", VIPS_VERSION_STRING );
vips_shutdown();
exit( 0 );
}
static GOptionEntry option_entries[] = { static GOptionEntry option_entries[] = {
{ "vips-info", 0, G_OPTION_FLAG_HIDDEN, { "vips-info", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_NONE, &vips__info, G_OPTION_ARG_CALLBACK, (gpointer) &vips_lib_info_cb,
N_( "show informative messages" ), NULL }, N_( "show informative messages" ), NULL },
{ "vips-fatal", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG, { "vips-fatal", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK, (gpointer) &vips_set_fatal_cb, G_OPTION_ARG_CALLBACK, (gpointer) &vips_set_fatal_cb,

View File

@ -177,7 +177,7 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
if( baseaddr == MAP_FAILED ) { if( baseaddr == MAP_FAILED ) {
vips_error_system( errno, "vips_mapfile", vips_error_system( errno, "vips_mapfile",
"%s", _( "unable to mmap" ) ); "%s", _( "unable to mmap" ) );
vips_warn( "vips_mapfile", _( "map failed (%s), " g_warning( _( "map failed (%s), "
"running very low on system resources, " "running very low on system resources, "
"expect a crash soon" ), strerror( errno ) ); "expect a crash soon" ), strerror( errno ) );
return( NULL ); return( NULL );

View File

@ -248,11 +248,9 @@ vips_tracked_free( void *s )
g_mutex_lock( vips_tracked_mutex ); g_mutex_lock( vips_tracked_mutex );
if( vips_tracked_allocs <= 0 ) if( vips_tracked_allocs <= 0 )
vips_warn( "vips_tracked", g_warning( "%s", _( "vips_free: too many frees" ) );
"%s", _( "vips_free: too many frees" ) );
if( vips_tracked_mem < size ) if( vips_tracked_mem < size )
vips_warn( "vips_tracked", g_warning( "%s", _( "vips_free: too much free" ) );
"%s", _( "vips_free: too much free" ) );
vips_tracked_mem -= size; vips_tracked_mem -= size;
vips_tracked_allocs -= 1; vips_tracked_allocs -= 1;
@ -310,8 +308,7 @@ vips_tracked_malloc( size_t size )
vips_error( "vips_tracked", vips_error( "vips_tracked",
_( "out of memory --- size == %dMB" ), _( "out of memory --- size == %dMB" ),
(int) (size / (1024.0 * 1024.0)) ); (int) (size / (1024.0 * 1024.0)) );
vips_warn( "vips_tracked", g_warning( _( "out of memory --- size == %dMB" ),
_( "out of memory --- size == %dMB" ),
(int) (size / (1024.0 * 1024.0)) ); (int) (size / (1024.0 * 1024.0)) );
return( NULL ); return( NULL );

View File

@ -221,12 +221,8 @@ vips_operation_finalize( GObject *gobject )
VIPS_DEBUG_MSG( "vips_operation_finalize: %p\n", gobject ); VIPS_DEBUG_MSG( "vips_operation_finalize: %p\n", gobject );
if( operation->pixels ) { if( operation->pixels )
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gobject ); g_info( _( "%d pixels calculated" ), operation->pixels );
vips_info( class->nickname,
_( "%d pixels calculated" ), operation->pixels );
}
G_OBJECT_CLASS( vips_operation_parent_class )->finalize( gobject ); G_OBJECT_CLASS( vips_operation_parent_class )->finalize( gobject );
} }

View File

@ -269,8 +269,7 @@ vips__region_stop( VipsRegion *region )
* can really do with it, sadly. * can really do with it, sadly.
*/ */
if( result ) if( result )
vips_warn( "VipsRegion", g_warning( "stop callback failed for image %s",
"stop callback failed for image %s",
image->filename ); image->filename );
region->seq = NULL; region->seq = NULL;

View File

@ -231,8 +231,7 @@ vips_system_build( VipsObject *object )
if( std_error ) { if( std_error ) {
vips__chomp( std_error ); vips__chomp( std_error );
if( strcmp( std_error, "" ) != 0 ) if( strcmp( std_error, "" ) != 0 )
vips_warn( class->nickname, g_warning( _( "stderr output: %s" ), std_error );
_( "stderr output: %s" ), std_error );
} }
if( std_output ) { if( std_output ) {
vips__chomp( std_output ); vips__chomp( std_output );

View File

@ -407,8 +407,7 @@ vips_concurrency_get( void )
if( nthr < 1 || nthr > MAX_THREADS ) { if( nthr < 1 || nthr > MAX_THREADS ) {
nthr = VIPS_CLIP( 1, nthr, MAX_THREADS ); nthr = VIPS_CLIP( 1, nthr, MAX_THREADS );
vips_warn( "vips_concurrency_get", g_warning( _( "threads clipped to %d" ), nthr );
_( "threads clipped to %d" ), nthr );
} }
/* Save for next time around. /* Save for next time around.

View File

@ -73,7 +73,7 @@ vips_vector_error( VipsVector *vector )
{ {
#ifdef HAVE_ORC_PROGRAM_GET_ERROR #ifdef HAVE_ORC_PROGRAM_GET_ERROR
if( vector->program ) if( vector->program )
vips_warn( "VipsVector", "orc error: %s", g_warning( "orc error: %s",
orc_program_get_error( vector->program ) ); orc_program_get_error( vector->program ) );
#endif /*HAVE_ORC_PROGRAM_GET_ERROR*/ #endif /*HAVE_ORC_PROGRAM_GET_ERROR*/
} }

View File

@ -915,8 +915,7 @@ vips_image_open_input( VipsImage *image )
return( -1 ); return( -1 );
image->file_length = rsize; image->file_length = rsize;
if( psize > rsize ) if( psize > rsize )
vips_warn( "VipsImage", g_warning( _( "unable to read data for \"%s\", %s" ),
_( "unable to read data for \"%s\", %s" ),
image->filename, _( "file has been truncated" ) ); image->filename, _( "file has been truncated" ) );
/* Set demand style. This suits a disc file we read sequentially. /* Set demand style. This suits a disc file we read sequentially.
@ -928,8 +927,7 @@ vips_image_open_input( VipsImage *image )
* harmless. * harmless.
*/ */
if( readhist( image ) ) { if( readhist( image ) ) {
vips_warn( "VipsImage", _( "error reading XML: %s" ), g_warning( _( "error reading XML: %s" ), vips_error_buffer() );
vips_error_buffer() );
vips_error_clear(); vips_error_clear();
} }

View File

@ -465,7 +465,7 @@ vips_reduceh_build( VipsObject *object )
*/ */
reduceh->n_point = reduceh->n_point =
vips_reduce_get_points( reduceh->kernel, reduceh->hshrink ); vips_reduce_get_points( reduceh->kernel, reduceh->hshrink );
vips_info( object_class->nickname, "%d point mask", reduceh->n_point ); g_info( "%d point mask", reduceh->n_point );
if( reduceh->n_point > MAX_POINT ) { if( reduceh->n_point > MAX_POINT ) {
vips_error( object_class->nickname, vips_error( object_class->nickname,
"%s", _( "reduce factor too large" ) ); "%s", _( "reduce factor too large" ) );

View File

@ -779,7 +779,7 @@ vips_reducev_raw( VipsReducev *reducev, VipsImage *in )
if( in->BandFmt == VIPS_FORMAT_UCHAR && if( in->BandFmt == VIPS_FORMAT_UCHAR &&
vips_vector_isenabled() && vips_vector_isenabled() &&
!vips_reducev_compile( reducev ) ) { !vips_reducev_compile( reducev ) ) {
vips_info( object_class->nickname, "using vector path" ); g_info( "using vector path" );
generate = vips_reducev_vector_gen; generate = vips_reducev_vector_gen;
} }
@ -848,7 +848,7 @@ vips_reducev_build( VipsObject *object )
"%s", _( "reduce factor too large" ) ); "%s", _( "reduce factor too large" ) );
return( -1 ); return( -1 );
} }
vips_info( object_class->nickname, "%d point mask", reducev->n_point ); g_info( "%d point mask", reducev->n_point );
/* Unpack for processing. /* Unpack for processing.
*/ */

View File

@ -155,7 +155,6 @@ vips_resize_interpolate( VipsKernel kernel )
static int static int
vips_resize_build( VipsObject *object ) vips_resize_build( VipsObject *object )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsResample *resample = VIPS_RESAMPLE( object ); VipsResample *resample = VIPS_RESAMPLE( object );
VipsResize *resize = (VipsResize *) object; VipsResize *resize = (VipsResize *) object;
@ -186,7 +185,7 @@ vips_resize_build( VipsObject *object )
int_vshrink = vips_resize_int_shrink( resize, vscale ); int_vshrink = vips_resize_int_shrink( resize, vscale );
if( int_vshrink > 1 ) { if( int_vshrink > 1 ) {
vips_info( class->nickname, "shrinkv by %d", int_vshrink ); g_info( "shrinkv by %d", int_vshrink );
if( vips_shrinkv( in, &t[0], int_vshrink, NULL ) ) if( vips_shrinkv( in, &t[0], int_vshrink, NULL ) )
return( -1 ); return( -1 );
in = t[0]; in = t[0];
@ -195,7 +194,7 @@ vips_resize_build( VipsObject *object )
} }
if( int_hshrink > 1 ) { if( int_hshrink > 1 ) {
vips_info( class->nickname, "shrinkh by %d", int_hshrink ); g_info( "shrinkh by %d", int_hshrink );
if( vips_shrinkh( in, &t[1], int_hshrink, NULL ) ) if( vips_shrinkh( in, &t[1], int_hshrink, NULL ) )
return( -1 ); return( -1 );
in = t[1]; in = t[1];
@ -251,8 +250,7 @@ vips_resize_build( VipsObject *object )
/* Any residual downsizing. /* Any residual downsizing.
*/ */
if( vscale < 1.0 ) { if( vscale < 1.0 ) {
vips_info( class->nickname, "residual reducev by %g", g_info( "residual reducev by %g", vscale );
vscale );
if( vips_reducev( in, &t[2], 1.0 / vscale, if( vips_reducev( in, &t[2], 1.0 / vscale,
"kernel", resize->kernel, "kernel", resize->kernel,
"centre", resize->centre, "centre", resize->centre,
@ -262,7 +260,7 @@ vips_resize_build( VipsObject *object )
} }
if( hscale < 1.0 ) { if( hscale < 1.0 ) {
vips_info( class->nickname, "residual reduceh by %g", g_info( "residual reduceh by %g",
hscale ); hscale );
if( vips_reduceh( in, &t[3], 1.0 / hscale, if( vips_reduceh( in, &t[3], 1.0 / hscale,
"kernel", resize->kernel, "kernel", resize->kernel,
@ -285,8 +283,7 @@ vips_resize_build( VipsObject *object )
if( hscale > 1.0 && if( hscale > 1.0 &&
vscale > 1.0 ) { vscale > 1.0 ) {
vips_info( class->nickname, g_info( "residual scale %g x %g", hscale, vscale );
"residual scale %g x %g", hscale, vscale );
if( vips_affine( in, &t[4], if( vips_affine( in, &t[4],
hscale, 0.0, 0.0, vscale, hscale, 0.0, 0.0, vscale,
"interpolate", interpolate, "interpolate", interpolate,
@ -295,8 +292,7 @@ vips_resize_build( VipsObject *object )
in = t[4]; in = t[4];
} }
else if( hscale > 1.0 ) { else if( hscale > 1.0 ) {
vips_info( class->nickname, g_info( "residual scale %g", hscale );
"residual scale %g", hscale );
if( vips_affine( in, &t[4], hscale, 0.0, 0.0, 1.0, if( vips_affine( in, &t[4], hscale, 0.0, 0.0, 1.0,
"interpolate", interpolate, "interpolate", interpolate,
NULL ) ) NULL ) )
@ -304,8 +300,7 @@ vips_resize_build( VipsObject *object )
in = t[4]; in = t[4];
} }
else { else {
vips_info( class->nickname, g_info( "residual scale %g", vscale );
"residual scale %g", vscale );
if( vips_affine( in, &t[4], 1.0, 0.0, 0.0, vscale, if( vips_affine( in, &t[4], 1.0, 0.0, 0.0, vscale,
"interpolate", interpolate, "interpolate", interpolate,
NULL ) ) NULL ) )

View File

@ -195,9 +195,8 @@ vips_thumbnail_open( VipsThumbnail *thumbnail )
if( class->get_info( thumbnail ) ) if( class->get_info( thumbnail ) )
return( NULL ); return( NULL );
vips_info( "thumbnail", "selected loader is %s", g_info( "selected loader is %s", thumbnail->loader );
thumbnail->loader ); g_info( "input size is %d x %d",
vips_info( "thumbnail", "input size is %d x %d",
thumbnail->input_width, thumbnail->input_height ); thumbnail->input_width, thumbnail->input_height );
shrink = 1; shrink = 1;
@ -206,21 +205,18 @@ vips_thumbnail_open( VipsThumbnail *thumbnail )
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) { if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
shrink = vips_thumbnail_find_jpegshrink( thumbnail, shrink = vips_thumbnail_find_jpegshrink( thumbnail,
thumbnail->input_width, thumbnail->input_height ); thumbnail->input_width, thumbnail->input_height );
vips_info( "thumbnail", g_info( "loading jpeg with factor %d pre-shrink", shrink );
"loading jpeg with factor %d pre-shrink", shrink );
} }
else if( vips_isprefix( "VipsForeignLoadPdf", thumbnail->loader ) || else if( vips_isprefix( "VipsForeignLoadPdf", thumbnail->loader ) ||
vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ) { vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ) {
scale = 1.0 / vips_thumbnail_calculate_shrink( thumbnail, scale = 1.0 / vips_thumbnail_calculate_shrink( thumbnail,
thumbnail->input_width, thumbnail->input_height ); thumbnail->input_width, thumbnail->input_height );
vips_info( "thumbnail", g_info( "loading PDF/SVG with factor %g pre-scale", scale );
"loading PDF/SVG with factor %g pre-scale", scale );
} }
else if( vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) { else if( vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
shrink = vips_thumbnail_calculate_shrink( thumbnail, shrink = vips_thumbnail_calculate_shrink( thumbnail,
thumbnail->input_width, thumbnail->input_height ); thumbnail->input_width, thumbnail->input_height );
vips_info( "thumbnail", g_info( "loading webp with factor %d pre-shrink", shrink );
"loading webp with factor %d pre-shrink", shrink );
} }
if( !(im = class->open( thumbnail, shrink, scale )) ) if( !(im = class->open( thumbnail, shrink, scale )) )
@ -269,7 +265,7 @@ vips_thumbnail_build( VipsObject *object )
/* RAD needs special unpacking. /* RAD needs special unpacking.
*/ */
if( in->Coding == VIPS_CODING_RAD ) { if( in->Coding == VIPS_CODING_RAD ) {
vips_info( "thumbnail", "unpacking Rad to float" ); g_info( "unpacking Rad to float" );
/* rad is scrgb. /* rad is scrgb.
*/ */
@ -296,11 +292,9 @@ vips_thumbnail_build( VipsObject *object )
(vips_image_get_typeof( in, VIPS_META_ICC_NAME ) || (vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ||
thumbnail->import_profile) ) { thumbnail->import_profile) ) {
if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) )
vips_info( "thumbnail", g_info( "importing with embedded profile" );
"importing with embedded profile" );
else else
vips_info( "thumbnail", g_info( "importing with profile %s",
"importing with profile %s",
thumbnail->import_profile ); thumbnail->import_profile );
if( vips_icc_import( in, &t[1], if( vips_icc_import( in, &t[1],
@ -317,7 +311,7 @@ vips_thumbnail_build( VipsObject *object )
/* To the processing colourspace. This will unpack LABQ as well. /* To the processing colourspace. This will unpack LABQ as well.
*/ */
vips_info( "thumbnail", "converting to processing space %s", g_info( "converting to processing space %s",
vips_enum_nick( VIPS_TYPE_INTERPRETATION, interpretation ) ); vips_enum_nick( VIPS_TYPE_INTERPRETATION, interpretation ) );
if( vips_colourspace( in, &t[2], interpretation, NULL ) ) if( vips_colourspace( in, &t[2], interpretation, NULL ) )
return( -1 ); return( -1 );
@ -328,7 +322,7 @@ vips_thumbnail_build( VipsObject *object )
*/ */
have_premultiplied = FALSE; have_premultiplied = FALSE;
if( vips_image_hasalpha( in ) ) { if( vips_image_hasalpha( in ) ) {
vips_info( "thumbnail", "premultiplying alpha" ); g_info( "premultiplying alpha" );
if( vips_premultiply( in, &t[3], NULL ) ) if( vips_premultiply( in, &t[3], NULL ) )
return( -1 ); return( -1 );
have_premultiplied = TRUE; have_premultiplied = TRUE;
@ -353,7 +347,7 @@ vips_thumbnail_build( VipsObject *object )
in = t[4]; in = t[4];
if( have_premultiplied ) { if( have_premultiplied ) {
vips_info( "thumbnail", "unpremultiplying alpha" ); g_info( "unpremultiplying alpha" );
if( vips_unpremultiply( in, &t[5], NULL ) || if( vips_unpremultiply( in, &t[5], NULL ) ||
vips_cast( t[5], &t[6], unpremultiplied_format, NULL ) ) vips_cast( t[5], &t[6], unpremultiplied_format, NULL ) )
return( -1 ); return( -1 );
@ -369,8 +363,7 @@ vips_thumbnail_build( VipsObject *object )
if( have_imported ) { if( have_imported ) {
if( thumbnail->export_profile || if( thumbnail->export_profile ||
vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) {
vips_info( "thumbnail", g_info( "exporting to device space with a profile" );
"exporting to device space with a profile" );
if( vips_icc_export( in, &t[7], if( vips_icc_export( in, &t[7],
"output_profile", thumbnail->export_profile, "output_profile", thumbnail->export_profile,
NULL ) ) NULL ) )
@ -378,7 +371,7 @@ vips_thumbnail_build( VipsObject *object )
in = t[7]; in = t[7];
} }
else { else {
vips_info( "thumbnail", "converting to sRGB" ); g_info( "converting to sRGB" );
if( vips_colourspace( in, &t[7], if( vips_colourspace( in, &t[7],
VIPS_INTERPRETATION_sRGB, NULL ) ) VIPS_INTERPRETATION_sRGB, NULL ) )
return( -1 ); return( -1 );
@ -390,23 +383,20 @@ vips_thumbnail_build( VipsObject *object )
thumbnail->import_profile) ) { thumbnail->import_profile) ) {
VipsImage *out; VipsImage *out;
vips_info( "thumbnail", g_info( "exporting with profile %s", thumbnail->export_profile );
"exporting with profile %s", thumbnail->export_profile );
/* We first try with the embedded profile, if any, then if /* We first try with the embedded profile, if any, then if
* that fails try again with the supplied fallback profile. * that fails try again with the supplied fallback profile.
*/ */
out = NULL; out = NULL;
if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) {
vips_info( "thumbnail", g_info( "importing with embedded profile" );
"importing with embedded profile" );
if( vips_icc_transform( in, &t[7], if( vips_icc_transform( in, &t[7],
thumbnail->export_profile, thumbnail->export_profile,
"embedded", TRUE, "embedded", TRUE,
NULL ) ) { NULL ) ) {
vips_warn( "thumbnail", g_warning( _( "unable to import with "
_( "unable to import with "
"embedded profile: %s" ), "embedded profile: %s" ),
vips_error_buffer() ); vips_error_buffer() );
@ -418,8 +408,7 @@ vips_thumbnail_build( VipsObject *object )
if( !out && if( !out &&
thumbnail->import_profile ) { thumbnail->import_profile ) {
vips_info( "thumbnail", g_info( "importing with fallback profile" );
"importing with fallback profile" );
if( vips_icc_transform( in, &t[7], if( vips_icc_transform( in, &t[7],
thumbnail->export_profile, thumbnail->export_profile,
@ -442,7 +431,7 @@ vips_thumbnail_build( VipsObject *object )
int left = (in->Xsize - thumbnail->width) / 2; int left = (in->Xsize - thumbnail->width) / 2;
int top = (in->Ysize - thumbnail->height) / 2; int top = (in->Ysize - thumbnail->height) / 2;
vips_info( "thumbnail", "cropping to %dx%d", g_info( "cropping to %dx%d",
thumbnail->width, thumbnail->height ); thumbnail->width, thumbnail->height );
if( vips_extract_area( in, &t[8], left, top, if( vips_extract_area( in, &t[8], left, top,
thumbnail->width, thumbnail->height, NULL ) ) thumbnail->width, thumbnail->height, NULL ) )
@ -454,7 +443,7 @@ vips_thumbnail_build( VipsObject *object )
thumbnail->angle != VIPS_ANGLE_D0 ) { thumbnail->angle != VIPS_ANGLE_D0 ) {
VipsAngle angle = vips_autorot_get_angle( in ); VipsAngle angle = vips_autorot_get_angle( in );
vips_info( "thumbnail", "rotating by %s", g_info( "rotating by %s",
vips_enum_nick( VIPS_TYPE_ANGLE, angle ) ); vips_enum_nick( VIPS_TYPE_ANGLE, angle ) );
/* Need to copy to memory, we have to stay seq. /* Need to copy to memory, we have to stay seq.
@ -573,7 +562,7 @@ vips_thumbnail_file_get_info( VipsThumbnail *thumbnail )
VipsImage *image; VipsImage *image;
vips_info( "thumbnail", "thumbnailing %s", file->filename ); g_info( "thumbnailing %s", file->filename );
if( !(thumbnail->loader = vips_foreign_find_load( file->filename )) || if( !(thumbnail->loader = vips_foreign_find_load( file->filename )) ||
!(image = vips_image_new_from_file( file->filename, NULL )) ) !(image = vips_image_new_from_file( file->filename, NULL )) )
@ -726,8 +715,7 @@ vips_thumbnail_buffer_get_info( VipsThumbnail *thumbnail )
VipsImage *image; VipsImage *image;
vips_info( "thumbnail", "thumbnailing %zd bytes of data", g_info( "thumbnailing %zd bytes of data", buffer->buf->length );
buffer->buf->length );
if( !(thumbnail->loader = vips_foreign_find_load_buffer( if( !(thumbnail->loader = vips_foreign_find_load_buffer(
buffer->buf->data, buffer->buf->length )) || buffer->buf->data, buffer->buf->length )) ||

View File

@ -213,8 +213,7 @@ thumbnail_write( VipsObject *process, VipsImage *im, const char *filename )
g_free( dir ); g_free( dir );
} }
vips_info( "vipsthumbnail", g_info( "thumbnailing %s as %s", filename, output_name );
"thumbnailing %s as %s", filename, output_name );
g_free( file ); g_free( file );
@ -308,7 +307,7 @@ main( int argc, char **argv )
if( rotate_image ) { if( rotate_image ) {
#ifndef HAVE_EXIF #ifndef HAVE_EXIF
vips_warn( "vipsthumbnail", "%s", g_warning( "%s",
_( "auto-rotate disabled: " _( "auto-rotate disabled: "
"libvips built without exif support" ) ); "libvips built without exif support" ) );
#endif /*!HAVE_EXIF*/ #endif /*!HAVE_EXIF*/