add stdin, stdout to vipsthumbnail
eg. vipsthumbnail stdin[page=2] -o .jpg[Q=90] mirror of syntax in new_from_file etc.
This commit is contained in:
parent
fbaa3c6dff
commit
a1505c6f72
@ -4,6 +4,7 @@
|
|||||||
- improve C++ API doc comments
|
- improve C++ API doc comments
|
||||||
- add VipsInterpolate and guint64 support to C++ API
|
- add VipsInterpolate and guint64 support to C++ API
|
||||||
- add VImage::new_from_memory_steal [Zeranoe]
|
- add VImage::new_from_memory_steal [Zeranoe]
|
||||||
|
- vipsthumbnail supports stdin / stdout thumbnailing
|
||||||
|
|
||||||
6/9/20 started 8.10.2
|
6/9/20 started 8.10.2
|
||||||
- update magicksave/load profile handling [kelilevi]
|
- update magicksave/load profile handling [kelilevi]
|
||||||
|
@ -102,6 +102,9 @@
|
|||||||
* - 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
|
||||||
@ -219,9 +222,11 @@ static GOptionEntry options[] = {
|
|||||||
|
|
||||||
/* 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;
|
||||||
@ -268,11 +273,13 @@ thumbnail_write( VipsObject *process, VipsImage *im, const char *filename )
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 )
|
||||||
@ -285,6 +292,7 @@ thumbnail_process( VipsObject *process, const char *filename )
|
|||||||
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;
|
||||||
@ -295,7 +303,32 @@ thumbnail_process( VipsObject *process, const char *filename )
|
|||||||
intent = n;
|
intent = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vips_thumbnail( filename, &image, thumbnail_width,
|
vips__filename_split8( name, filename, option_string );
|
||||||
|
if( strcmp( filename, "stdin" ) == 0 ) {
|
||||||
|
VipsSource *source;
|
||||||
|
|
||||||
|
if( !(source =
|
||||||
|
vips_source_new_from_descriptor( 0 )) )
|
||||||
|
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,
|
"height", thumbnail_height,
|
||||||
"size", size_restriction,
|
"size", size_restriction,
|
||||||
"no-rotate", no_rotate_image,
|
"no-rotate", no_rotate_image,
|
||||||
@ -306,13 +339,37 @@ thumbnail_process( VipsObject *process, const char *filename )
|
|||||||
"intent", intent,
|
"intent", intent,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
if( thumbnail_write( process, image, filename ) ) {
|
/* If the output format is something like ".jpg", we write to stdout
|
||||||
g_object_unref( image );
|
* 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 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref( image );
|
VIPS_UNREF( target );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( thumbnail_write_file( process, image, name ) ) {
|
||||||
|
VIPS_UNREF( image );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VIPS_UNREF( image );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user