vipsheader allows stdin as a filename
``` $ cat k2.jpg | vipsheader stdin 1450x2048 uchar, 3 bands, srgb, jpegload_source ``` See https://github.com/libvips/libvips/issues/1594
This commit is contained in:
parent
e1a4b98be9
commit
2b2fabcd3b
@ -39,6 +39,7 @@
|
|||||||
- reduce operation cache max to 100
|
- reduce operation cache max to 100
|
||||||
- rework the final bits of vips7 for vips8 [kleisauke]
|
- rework the final bits of vips7 for vips8 [kleisauke]
|
||||||
- --disable-deprecated now works [kleisauke]
|
- --disable-deprecated now works [kleisauke]
|
||||||
|
- vipsheader allows "stdin" as a filename
|
||||||
|
|
||||||
24/4/20 started 8.9.3
|
24/4/20 started 8.9.3
|
||||||
- better iiif tile naming [IllyaMoskvin]
|
- better iiif tile naming [IllyaMoskvin]
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
* functions, so "header" is now obsolete
|
* functions, so "header" is now obsolete
|
||||||
* 27/2/13
|
* 27/2/13
|
||||||
* - convert to vips8 API
|
* - convert to vips8 API
|
||||||
|
* 29/6/20
|
||||||
|
* - allow "stdin" as a filename
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -109,7 +111,8 @@ print_field_fn( VipsImage *image, const char *field, GValue *value, void *a )
|
|||||||
char str[256];
|
char str[256];
|
||||||
VipsBuf buf = VIPS_BUF_STATIC( str );
|
VipsBuf buf = VIPS_BUF_STATIC( str );
|
||||||
|
|
||||||
if( *many )
|
if( *many &&
|
||||||
|
image->filename )
|
||||||
printf( "%s: ", image->filename );
|
printf( "%s: ", image->filename );
|
||||||
|
|
||||||
printf( "%s: ", field );
|
printf( "%s: ", field );
|
||||||
@ -123,33 +126,35 @@ print_field_fn( VipsImage *image, const char *field, GValue *value, void *a )
|
|||||||
/* Print header, or parts of header.
|
/* Print header, or parts of header.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
print_header( VipsImage *im, gboolean many )
|
print_header( VipsImage *image, gboolean many )
|
||||||
{
|
{
|
||||||
if( !main_option_field ) {
|
if( !main_option_field ) {
|
||||||
printf( "%s: ", im->filename );
|
if( image->filename )
|
||||||
|
printf( "%s: ", image->filename );
|
||||||
|
|
||||||
vips_object_print_summary( VIPS_OBJECT( im ) );
|
vips_object_print_summary( VIPS_OBJECT( image ) );
|
||||||
|
|
||||||
if( main_option_all )
|
if( main_option_all )
|
||||||
(void) vips_image_map( im, print_field_fn, &many );
|
(void) vips_image_map( image, print_field_fn, &many );
|
||||||
}
|
}
|
||||||
else if( strcmp( main_option_field, "getext" ) == 0 ) {
|
else if( strcmp( main_option_field, "getext" ) == 0 ) {
|
||||||
if( vips__has_extension_block( im ) ) {
|
if( vips__has_extension_block( image ) ) {
|
||||||
void *buf;
|
void *buf;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if( !(buf = vips__read_extension_block( im, &size )) )
|
if( !(buf =
|
||||||
|
vips__read_extension_block( image, &size )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
printf( "%s", (char *) buf );
|
printf( "%s", (char *) buf );
|
||||||
g_free( buf );
|
g_free( buf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( strcmp( main_option_field, "Hist" ) == 0 )
|
else if( strcmp( main_option_field, "Hist" ) == 0 )
|
||||||
printf( "%s", vips_image_get_history( im ) );
|
printf( "%s", vips_image_get_history( image ) );
|
||||||
else {
|
else {
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if( vips_image_get_as_string( im, main_option_field, &str ) )
|
if( vips_image_get_as_string( image, main_option_field, &str ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
printf( "%s\n", str );
|
printf( "%s\n", str );
|
||||||
g_free( str );
|
g_free( str );
|
||||||
@ -205,21 +210,39 @@ main( int argc, char *argv[] )
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
for( i = 1; argv[i]; i++ ) {
|
for( i = 1; argv[i]; i++ ) {
|
||||||
VipsImage *im;
|
VipsImage *image;
|
||||||
|
char filename[VIPS_PATH_MAX];
|
||||||
|
char option_string[VIPS_PATH_MAX];
|
||||||
|
|
||||||
if( !(im = vips_image_new_from_file( argv[i], NULL )) ) {
|
vips__filename_split8( argv[i], filename, option_string );
|
||||||
|
if( strcmp( filename, "stdin" ) == 0 ) {
|
||||||
|
VipsSource *source;
|
||||||
|
|
||||||
|
if( !(source = vips_source_new_from_descriptor( 0 )) )
|
||||||
|
return( -1 );
|
||||||
|
if( !(image = vips_image_new_from_source( source,
|
||||||
|
option_string, NULL )) ) {
|
||||||
|
VIPS_UNREF( source );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
VIPS_UNREF( source );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( !(image =
|
||||||
|
vips_image_new_from_file( argv[i], NULL )) ) {
|
||||||
|
print_error();
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( image &&
|
||||||
|
print_header( image, argv[2] != NULL ) ) {
|
||||||
print_error();
|
print_error();
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( im &&
|
if( image )
|
||||||
print_header( im, argv[2] != NULL ) ) {
|
g_object_unref( image );
|
||||||
print_error();
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( im )
|
|
||||||
g_object_unref( im );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't free this on error exit, sadly.
|
/* We don't free this on error exit, sadly.
|
||||||
|
Loading…
Reference in New Issue
Block a user