"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/vipsthumbnail.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

vipsthumbnail.c  (vips-8.10.6):vipsthumbnail.c  (vips-8.11.0)
skipping to change at line 105 skipping to change at line 105
* 30/8/17 * 30/8/17
* - add --intent * - add --intent
* 23/10/17 * 23/10/17
* - --size Nx didn't work, argh ... thanks jrochkind * - --size Nx didn't work, argh ... thanks jrochkind
* 3/2/20 * 3/2/20
* - add --no-rotate * - add --no-rotate
* - add --import-profile / --export-profile names * - add --import-profile / --export-profile names
* - back to -o for output * - back to -o for output
* 29/2/20 * 29/2/20
* - deprecate --delete * - deprecate --delete
* 2/10/20
* - support "stdin" as a magic input filename for thumbnail_source
* - support ".suffix" as a magic ouput format for stdout write
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif /*HAVE_CONFIG_H*/ #endif /*HAVE_CONFIG_H*/
#include <vips/intl.h> #include <vips/intl.h>
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
skipping to change at line 222 skipping to change at line 225
G_OPTION_ARG_STRING, &interpolator, G_OPTION_ARG_STRING, &interpolator,
N_( "(deprecated, does nothing)" ), NULL }, N_( "(deprecated, does nothing)" ), NULL },
{ "sharpen", 'r', G_OPTION_FLAG_HIDDEN, { "sharpen", 'r', G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_STRING, &convolution_mask, G_OPTION_ARG_STRING, &convolution_mask,
N_( "(deprecated, does nothing)" ), NULL }, N_( "(deprecated, does nothing)" ), NULL },
{ NULL } { NULL }
}; };
/* Given (eg.) "/poop/somefile.png", write @im to the thumbnail name, /* Given (eg.) "/poop/somefile.png", write @im to the thumbnail name,
* (eg.) "/poop/tn_somefile.jpg". * (eg.) "/poop/tn_somefile.jpg".
*
* If
*/ */
static int static int
thumbnail_write( VipsObject *process, VipsImage *im, const char *filename ) thumbnail_write_file( VipsObject *process, VipsImage *im, const char *filename )
{ {
char *file; char *file;
char *p; char *p;
char buf[FILENAME_MAX]; char buf[FILENAME_MAX];
char *output_name; char *output_name;
file = g_path_get_basename( filename ); file = g_path_get_basename( filename );
/* Remove the suffix from the file portion. /* Remove the suffix from the file portion.
*/ */
skipping to change at line 271 skipping to change at line 276
if( vips_image_write_to_file( im, output_name, NULL ) ) { if( vips_image_write_to_file( im, output_name, NULL ) ) {
g_free( output_name ); g_free( output_name );
return( -1 ); return( -1 );
} }
g_free( output_name ); g_free( output_name );
return( 0 ); return( 0 );
} }
static int static int
thumbnail_process( VipsObject *process, const char *filename ) thumbnail_process( VipsObject *process, const char *name )
{ {
VipsInteresting interesting; VipsInteresting interesting;
VipsImage *image; VipsImage *image;
VipsIntent intent; VipsIntent intent;
char filename[VIPS_PATH_MAX];
char option_string[VIPS_PATH_MAX];
interesting = VIPS_INTERESTING_NONE; interesting = VIPS_INTERESTING_NONE;
if( crop_image ) if( crop_image )
interesting = VIPS_INTERESTING_CENTRE; interesting = VIPS_INTERESTING_CENTRE;
if( smartcrop_image ) { if( smartcrop_image ) {
int n; int n;
if( (n = vips_enum_from_nick( "vipsthumbnail", if( (n = vips_enum_from_nick( "vipsthumbnail",
VIPS_TYPE_INTERESTING, smartcrop_image )) < 0 ) VIPS_TYPE_INTERESTING, smartcrop_image )) < 0 )
return( -1 ); return( -1 );
interesting = n; interesting = n;
} }
intent = VIPS_INTENT_RELATIVE; intent = VIPS_INTENT_RELATIVE;
if( thumbnail_intent ) { if( thumbnail_intent ) {
int n; int n;
if( (n = vips_enum_from_nick( "vipsthumbnail", if( (n = vips_enum_from_nick( "vipsthumbnail",
VIPS_TYPE_INTENT, thumbnail_intent )) < 0 ) VIPS_TYPE_INTENT, thumbnail_intent )) < 0 )
return( -1 ); return( -1 );
intent = n; intent = n;
} }
if( vips_thumbnail( filename, &image, thumbnail_width, vips__filename_split8( name, filename, option_string );
"height", thumbnail_height, if( strcmp( filename, "stdin" ) == 0 ) {
"size", size_restriction, VipsSource *source;
"no-rotate", no_rotate_image,
"crop", interesting,
"linear", linear_processing,
"import-profile", import_profile,
"export-profile", export_profile,
"intent", intent,
NULL ) )
return( -1 );
if( thumbnail_write( process, image, filename ) ) { if( !(source =
g_object_unref( image ); vips_source_new_from_descriptor( 0 )) )
return( -1 ); return( -1 );
if( vips_thumbnail_source( source, &image, thumbnail_width,
"option-string", option_string,
"height", thumbnail_height,
"size", size_restriction,
"no-rotate", no_rotate_image,
"crop", interesting,
"linear", linear_processing,
"import-profile", import_profile,
"export-profile", export_profile,
"intent", intent,
NULL ) ) {
VIPS_UNREF( source );
return( -1 );
}
VIPS_UNREF( source );
}
else {
if( vips_thumbnail( name, &image, thumbnail_width,
"height", thumbnail_height,
"size", size_restriction,
"no-rotate", no_rotate_image,
"crop", interesting,
"linear", linear_processing,
"import-profile", import_profile,
"export-profile", export_profile,
"intent", intent,
NULL ) )
return( -1 );
}
/* If the output format is something like ".jpg", we write to stdout
* instead.
*
* (but allow "./%s.jpg" as a output format)
*/
if( vips_isprefix( ".", output_format ) &&
!vips_isprefix( "./", output_format ) ) {
VipsTarget *target;
if( !(target = vips_target_new_to_descriptor( 1 )) )
return( -1 );
if( vips_image_write_to_target( image,
output_format, target, NULL ) ) {
VIPS_UNREF( image );
VIPS_UNREF( target );
return( -1 );
}
VIPS_UNREF( target );
}
else {
if( thumbnail_write_file( process, image, name ) ) {
VIPS_UNREF( image );
return( -1 );
}
} }
g_object_unref( image ); VIPS_UNREF( image );
return( 0 ); return( 0 );
} }
/* Parse a geometry string and set thumbnail_width and thumbnail_height. /* Parse a geometry string and set thumbnail_width and thumbnail_height.
*/ */
static int static int
thumbnail_parse_geometry( const char *geometry ) thumbnail_parse_geometry( const char *geometry )
{ {
/* Geometry strings have a regex like: /* Geometry strings have a regex like:
skipping to change at line 446 skipping to change at line 503
textdomain( GETTEXT_PACKAGE ); textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" ); setlocale( LC_ALL, "" );
/* The operation cache is not useful for processing many files. /* The operation cache is not useful for processing many files.
vips_cache_set_max( 0 ); vips_cache_set_max( 0 );
*/ */
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of /* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args. * the args.
*/ */
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE #ifdef G_OS_WIN32
argv = g_win32_get_command_line(); argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/ #endif /*G_OS_WIN32*/
context = g_option_context_new( _( "- thumbnail generator" ) ); context = g_option_context_new( _( "- thumbnail generator" ) );
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL ); main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
g_option_group_add_entries( main_group, options ); g_option_group_add_entries( main_group, options );
vips_add_option_entries( main_group ); vips_add_option_entries( main_group );
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE ); g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group ); g_option_context_set_main_group( context, main_group );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE #ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) ) if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/ #else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, &argc, &argv, &error ) ) if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/ #endif /*G_OS_WIN32*/
{ {
if( error ) { if( error ) {
fprintf( stderr, "%s\n", error->message ); fprintf( stderr, "%s\n", error->message );
g_error_free( error ); g_error_free( error );
} }
vips_error_exit( "try \"%s --help\"", g_get_prgname() ); vips_error_exit( "try \"%s --help\"", g_get_prgname() );
} }
g_option_context_free( context ); g_option_context_free( context );
skipping to change at line 509 skipping to change at line 566
* when we finally exit. * when we finally exit.
*/ */
result = -1; result = -1;
} }
g_object_unref( process ); g_object_unref( process );
} }
/* We don't free this on error exit, sadly. /* We don't free this on error exit, sadly.
*/ */
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE #ifdef G_OS_WIN32
g_strfreev( argv ); g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/ #endif /*G_OS_WIN32*/
vips_shutdown(); vips_shutdown();
return( result ); return( result );
} }
 End of changes. 16 change blocks. 
24 lines changed or deleted 81 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)