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:
$ 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 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
- 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,
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 ) {
vips_foreign_load_magick7_error( magick7 );
return( -1 );
@ -579,8 +590,10 @@ vips_foreign_load_magick7_file_header( VipsForeignLoad *load )
return( -1 );
/* 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.
*/
if( !magick7->all_frames )
VIPS_FREEF( DestroyImageList, magick7->image );
VIPS_SETSTR( load->out->filename, file->filename );
@ -597,12 +610,15 @@ vips_foreign_load_magick7_file_load( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_file_load: %p\n", load );
#endif /*DEBUG*/
if( !magick7->all_frames ) {
g_assert( !magick7->image );
magick7->image = ReadImage( magick7->image_info, magick7->exception );
magick7->image =
ReadImage( magick7->image_info, magick7->exception );
if( !magick7->image ) {
vips_foreign_load_magick7_error( magick7 );
return( -1 );
}
}
if( vips_foreign_load_magick7_load( magick7 ) )
return( -1 );
@ -688,9 +704,18 @@ vips_foreign_load_magick7_buffer_header( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_buffer_header: %p\n", load );
#endif /*DEBUG*/
/* See comments on file load above ^^ for notes on the all_frames
* handling.
*/
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 ) {
vips_foreign_load_magick7_error( magick7 );
return( -1 );
@ -708,6 +733,7 @@ vips_foreign_load_magick7_buffer_header( VipsForeignLoad *load )
/* No longer need the ping result, and we'll replace ->image with Read
* when we do that later.
*/
if( !magick7->all_frames )
VIPS_FREEF( DestroyImageList, magick7->image );
return( 0 );
@ -724,6 +750,9 @@ vips_foreign_load_magick7_buffer_load( VipsForeignLoad *load )
printf( "vips_foreign_load_magick7_buffer_load: %p\n", load );
#endif /*DEBUG*/
if( !magick7->all_frames ) {
g_assert( !magick7->image );
magick7->image = BlobToImage( magick7->image_info,
magick7_buffer->buf->data, magick7_buffer->buf->length,
magick7->exception );
@ -731,6 +760,7 @@ vips_foreign_load_magick7_buffer_load( VipsForeignLoad *load )
vips_foreign_load_magick7_error( magick7 );
return( -1 );
}
}
if( vips_foreign_load_magick7_load( magick7 ) )
return( -1 );