vipsthumbnail sets an error on failure

conversion errors are ignored as before, but on final exit vipsthumbnail will
return an error code if one or more of the conversions failed

see https://github.com/jcupitt/libvips/issues/219
This commit is contained in:
John Cupitt 2015-01-13 17:31:09 +00:00
parent 6a327ffde7
commit c805b382fe
3 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,7 @@
- more tests - more tests
- renamed VIPS_FOREIGN_DZ_DEPTH_1 as VIPS_FOREIGN_DZ_DEPTH_ONE etc. to help - renamed VIPS_FOREIGN_DZ_DEPTH_1 as VIPS_FOREIGN_DZ_DEPTH_ONE etc. to help
bindings bindings
- vipsthumbnail will return an error code if one or more conversions failed
24/12/14 started 7.42.1 24/12/14 started 7.42.1
- add gobject-2.0 to Requires: in vips and vips-cpp .pc files - add gobject-2.0 to Requires: in vips and vips-cpp .pc files

View File

@ -120,6 +120,8 @@ normally runs silently, except for warning and error messages. This option
makes it print a list of the operations it performs on each image. makes it print a list of the operations it performs on each image.
.SH RETURN VALUE .SH RETURN VALUE
returns 0 on success and non-zero on error. returns 0 on success and non-zero on error. Error can mean one or more
conversions failed.
.SH SEE ALSO .SH SEE ALSO
vipsheader(1) vipsheader(1)

View File

@ -61,6 +61,8 @@
* 12/9/14 * 12/9/14
* - try with embedded profile first, if that fails retry with fallback * - try with embedded profile first, if that fails retry with fallback
* profile * profile
* 13/1/15
* - exit with an error code if one or more conversions failed
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -730,6 +732,7 @@ main( int argc, char **argv )
GOptionGroup *main_group; GOptionGroup *main_group;
GError *error = NULL; GError *error = NULL;
int i; int i;
int result;
if( VIPS_INIT( argv[0] ) ) if( VIPS_INIT( argv[0] ) )
vips_error_exit( "unable to start VIPS" ); vips_error_exit( "unable to start VIPS" );
@ -770,6 +773,8 @@ main( int argc, char **argv )
thumbnail_height = thumbnail_width; thumbnail_height = thumbnail_width;
} }
result = 0;
for( i = 1; i < argc; i++ ) { for( i = 1; i < argc; i++ ) {
/* Hang resources for processing this thumbnail off @process. /* Hang resources for processing this thumbnail off @process.
*/ */
@ -780,6 +785,11 @@ main( int argc, char **argv )
argv[0], argv[i] ); argv[0], argv[i] );
fprintf( stderr, "%s", vips_error_buffer() ); fprintf( stderr, "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
/* We had a conversion failure: return an error code
* when we finally exit.
*/
result = -1;
} }
g_object_unref( process ); g_object_unref( process );
@ -787,5 +797,5 @@ main( int argc, char **argv )
vips_shutdown(); vips_shutdown();
return( 0 ); return( result );
} }