fix all_pages

tested with pdf, need to test gif
This commit is contained in:
John Cupitt 2016-07-25 13:57:50 +01:00
parent 12a32b23f1
commit 27da050a24
2 changed files with 62 additions and 28 deletions

24
TODO
View File

@ -7,20 +7,24 @@
try with convert, get a one-band png, no alpha at all try with convert, get a one-band png, no alpha at all
- try:
$ time vips magickload nipguide.pdf x.tif
VipsForeignLoad: images do not match
vips__region_start: start function failed for image nipguide.pdf
VipsRegion: images do not match in pixel size
- try loading one page of a PDF with the new magickload
- try loading one page of a GIF with the new magickload - try loading one page of a GIF with the new magickload
- try loading a DICOM - try loading a DICOM
- add tests:
load 1 page of a pdf/gif
load all frames from a pdf/gif
svg alpha
density
png alpha
dicom?
all with file and buffer source
- add more webp tests to py suite - add more webp tests to py suite
- try moving some more of the CLI tests to py - try moving some more of the CLI tests to py

View File

@ -563,7 +563,18 @@ vips_foreign_load_magick7_file_header( VipsForeignLoad *load )
vips_strncpy( magick7->image_info->filename, file->filename, vips_strncpy( magick7->image_info->filename, file->filename,
MagickPathExtent ); MagickPathExtent );
magick7->image = PingImage( magick7->image_info, magick7->exception ); /* If we're reading all_frames, we can't just ping, we have to read the
* whole thing, since ping does not set up the image list.
*
* Hopefully, all_frames is only used rarely.
*/
if( magick7->all_frames )
magick7->image =
ReadImage( magick7->image_info, magick7->exception );
else
magick7->image =
PingImage( magick7->image_info, magick7->exception );
if( !magick7->image ) { if( !magick7->image ) {
vips_foreign_load_magick7_error( magick7 ); vips_foreign_load_magick7_error( magick7 );
return( -1 ); return( -1 );
@ -579,9 +590,11 @@ vips_foreign_load_magick7_file_header( VipsForeignLoad *load )
return( -1 ); return( -1 );
/* No longer need the ping result, and we'll replace ->image with Read /* No longer need the ping result, and we'll replace ->image with Read
* when we do that later. * when we do that later. If we're reading all_frames, we will reuse
* the read, so don't free.
*/ */
VIPS_FREEF( DestroyImageList, magick7->image ); if( !magick7->all_frames )
VIPS_FREEF( DestroyImageList, magick7->image );
VIPS_SETSTR( load->out->filename, file->filename ); VIPS_SETSTR( load->out->filename, file->filename );
@ -597,11 +610,14 @@ vips_foreign_load_magick7_file_load( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_file_load: %p\n", load ); printf( "vips_foreign_load_magick7_file_load: %p\n", load );
#endif /*DEBUG*/ #endif /*DEBUG*/
g_assert( !magick7->image ); if( !magick7->all_frames ) {
magick7->image = ReadImage( magick7->image_info, magick7->exception ); g_assert( !magick7->image );
if( !magick7->image ) { magick7->image =
vips_foreign_load_magick7_error( magick7 ); ReadImage( magick7->image_info, magick7->exception );
return( -1 ); if( !magick7->image ) {
vips_foreign_load_magick7_error( magick7 );
return( -1 );
}
} }
if( vips_foreign_load_magick7_load( magick7 ) ) if( vips_foreign_load_magick7_load( magick7 ) )
@ -688,9 +704,18 @@ vips_foreign_load_magick7_buffer_header( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_buffer_header: %p\n", load ); printf( "vips_foreign_load_magick7_buffer_header: %p\n", load );
#endif /*DEBUG*/ #endif /*DEBUG*/
magick7->image = PingBlob( magick7->image_info, /* See comments on file load above ^^ for notes on the all_frames
magick7_buffer->buf->data, magick7_buffer->buf->length, * handling.
magick7->exception ); */
if( magick7->all_frames )
magick7->image = BlobToImage( magick7->image_info,
magick7_buffer->buf->data, magick7_buffer->buf->length,
magick7->exception );
else
magick7->image = PingBlob( magick7->image_info,
magick7_buffer->buf->data, magick7_buffer->buf->length,
magick7->exception );
if( !magick7->image ) { if( !magick7->image ) {
vips_foreign_load_magick7_error( magick7 ); vips_foreign_load_magick7_error( magick7 );
return( -1 ); return( -1 );
@ -708,7 +733,8 @@ vips_foreign_load_magick7_buffer_header( VipsForeignLoad *load )
/* No longer need the ping result, and we'll replace ->image with Read /* No longer need the ping result, and we'll replace ->image with Read
* when we do that later. * when we do that later.
*/ */
VIPS_FREEF( DestroyImageList, magick7->image ); if( !magick7->all_frames )
VIPS_FREEF( DestroyImageList, magick7->image );
return( 0 ); return( 0 );
} }
@ -724,12 +750,16 @@ vips_foreign_load_magick7_buffer_load( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_buffer_load: %p\n", load ); printf( "vips_foreign_load_magick7_buffer_load: %p\n", load );
#endif /*DEBUG*/ #endif /*DEBUG*/
magick7->image = BlobToImage( magick7->image_info, if( !magick7->all_frames ) {
magick7_buffer->buf->data, magick7_buffer->buf->length, g_assert( !magick7->image );
magick7->exception );
if( !magick7->image ) { magick7->image = BlobToImage( magick7->image_info,
vips_foreign_load_magick7_error( magick7 ); magick7_buffer->buf->data, magick7_buffer->buf->length,
return( -1 ); magick7->exception );
if( !magick7->image ) {
vips_foreign_load_magick7_error( magick7 );
return( -1 );
}
} }
if( vips_foreign_load_magick7_load( magick7 ) ) if( vips_foreign_load_magick7_load( magick7 ) )