mostly works now
but cat k2.jpg | vips copy stdin x.jpg still fails
This commit is contained in:
parent
e27d6448b1
commit
a9a0dfee0f
|
@ -717,7 +717,8 @@ vips_image_get_yoffset( const VipsImage *image )
|
||||||
* vips_image_get_filename: (method)
|
* vips_image_get_filename: (method)
|
||||||
* @image: image to get from
|
* @image: image to get from
|
||||||
*
|
*
|
||||||
* Returns: the name of the file the image was loaded from.
|
* Returns: the name of the file the image was loaded from, or NULL if there
|
||||||
|
* is no filename.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
vips_image_get_filename( const VipsImage *image )
|
vips_image_get_filename( const VipsImage *image )
|
||||||
|
|
|
@ -670,9 +670,6 @@ vips_image_sanity( VipsObject *object, VipsBuf *buf )
|
||||||
{
|
{
|
||||||
VipsImage *image = VIPS_IMAGE( object );
|
VipsImage *image = VIPS_IMAGE( object );
|
||||||
|
|
||||||
if( !image->filename )
|
|
||||||
vips_buf_appends( buf, "NULL filename\n" );
|
|
||||||
|
|
||||||
/* All 0 means im has been inited but never used.
|
/* All 0 means im has been inited but never used.
|
||||||
*/
|
*/
|
||||||
if( image->Xsize != 0 ||
|
if( image->Xsize != 0 ||
|
||||||
|
|
|
@ -98,11 +98,13 @@ vips_streami_sanity( VipsStreami *streami )
|
||||||
*/
|
*/
|
||||||
g_assert( !streami->is_pipe );
|
g_assert( !streami->is_pipe );
|
||||||
|
|
||||||
/* Read position must lie within the buffer.
|
/* Read position must lie within the buffer. <= length, since
|
||||||
|
* it can be one beyond. Imagine read_position 0 and a
|
||||||
|
* zero-length buffer.
|
||||||
*/
|
*/
|
||||||
g_assert( streami->read_position >= 0 );
|
g_assert( streami->read_position >= 0 );
|
||||||
g_assert( streami->read_position < streami->length );
|
g_assert( streami->read_position <= streami->length );
|
||||||
g_assert( streami->read_position <
|
g_assert( streami->read_position <=
|
||||||
VIPS_AREA( streami->blob )->length );
|
VIPS_AREA( streami->blob )->length );
|
||||||
|
|
||||||
/* No need for header tracking.
|
/* No need for header tracking.
|
||||||
|
@ -126,7 +128,8 @@ vips_streami_sanity( VipsStreami *streami )
|
||||||
*/
|
*/
|
||||||
g_assert( !streami->decode ||
|
g_assert( !streami->decode ||
|
||||||
(streami->read_position >= 0 &&
|
(streami->read_position >= 0 &&
|
||||||
streami->read_position < streami->header_bytes->len) );
|
streami->read_position <=
|
||||||
|
streami->header_bytes->len) );
|
||||||
|
|
||||||
/* If we're in the header, we must save bytes we read. If not
|
/* If we're in the header, we must save bytes we read. If not
|
||||||
* in header, should have no saved bytes.
|
* in header, should have no saved bytes.
|
||||||
|
@ -165,16 +168,16 @@ vips_streami_sanity( VipsStreami *streami )
|
||||||
/* Read position must lie within the file.
|
/* Read position must lie within the file.
|
||||||
*/
|
*/
|
||||||
g_assert( streami->read_position >= 0 );
|
g_assert( streami->read_position >= 0 );
|
||||||
g_assert( streami->read_position < streami->length );
|
g_assert( streami->read_position <= streami->length );
|
||||||
|
|
||||||
/* No need for header tracking.
|
/* No need for header tracking.
|
||||||
*/
|
*/
|
||||||
g_assert( !streami->header_bytes );
|
g_assert( !streami->header_bytes );
|
||||||
|
|
||||||
/* Only have sniff during header,
|
/* Only have sniff during header read.
|
||||||
*/
|
*/
|
||||||
g_assert( streami->decode ||
|
g_assert( (streami->decode && !streami->sniff) ||
|
||||||
!streami->sniff );
|
(!streami->decode && streami->sniff) );
|
||||||
|
|
||||||
/* Supports minimise, so if descriptor is -1, we must have a
|
/* Supports minimise, so if descriptor is -1, we must have a
|
||||||
* filename we can reopen.
|
* filename we can reopen.
|
||||||
|
@ -227,13 +230,21 @@ vips_streami_build( VipsObject *object )
|
||||||
/* If there's a descriptor for streami, test its properties.
|
/* If there's a descriptor for streami, test its properties.
|
||||||
*/
|
*/
|
||||||
if( stream->descriptor != -1 ) {
|
if( stream->descriptor != -1 ) {
|
||||||
/* Do +=0 on the current position. This fails for pipes, at
|
/* Can we seek? If not, this is some kind of pipe.
|
||||||
* least on linux.
|
|
||||||
*/
|
*/
|
||||||
if( vips__seek( stream->descriptor, 0, SEEK_CUR ) != -1 )
|
if( vips__seek( stream->descriptor, 0, SEEK_CUR ) == -1 ) {
|
||||||
|
VIPS_DEBUG_MSG( " not seekable\n" );
|
||||||
streami->is_pipe = TRUE;
|
streami->is_pipe = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try and get the length. Don't bother for pipes.
|
||||||
|
*/
|
||||||
|
if( !streami->is_pipe &&
|
||||||
|
(streami->length =
|
||||||
|
vips_file_length( stream->descriptor )) == -1 )
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
/* Need to save the header for pipe-style sources.
|
/* Need to save the header for pipe-style sources.
|
||||||
*/
|
*/
|
||||||
if( streami->is_pipe )
|
if( streami->is_pipe )
|
||||||
|
@ -345,10 +356,6 @@ vips_streami_unminimise_real( VipsStreami *streami )
|
||||||
stream->tracked_descriptor = fd;
|
stream->tracked_descriptor = fd;
|
||||||
stream->descriptor = fd;
|
stream->descriptor = fd;
|
||||||
|
|
||||||
if( streami->length == -1 &&
|
|
||||||
(streami->length = vips_file_length( fd )) == -1 )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_streami_unminimise_real: "
|
VIPS_DEBUG_MSG( "vips_streami_unminimise_real: "
|
||||||
"restoring read position %zd\n",
|
"restoring read position %zd\n",
|
||||||
streami->read_position );
|
streami->read_position );
|
||||||
|
@ -846,17 +853,12 @@ vips_streami_minimise( VipsStreami *streami )
|
||||||
int
|
int
|
||||||
vips_streami_unminimise( VipsStreami *streami )
|
vips_streami_unminimise( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
int result;
|
|
||||||
|
|
||||||
VipsStreamiClass *class = VIPS_STREAMI_GET_CLASS( streami );
|
VipsStreamiClass *class = VIPS_STREAMI_GET_CLASS( streami );
|
||||||
|
|
||||||
vips_streami_sanity( streami );
|
/* This is used during _build(), so we can't sanity check
|
||||||
|
*/
|
||||||
|
|
||||||
result = class->unminimise( streami );
|
return( class->unminimise( streami ) );
|
||||||
|
|
||||||
vips_streami_sanity( streami );
|
|
||||||
|
|
||||||
return( result );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint64
|
gint64
|
||||||
|
|
Loading…
Reference in New Issue