diff --git a/TODO b/TODO index e4594c69..4102778e 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,14 @@ +- can't read all frames of a gif, we get n_frames = 1 + + if all_frames is set, we need to set image_info->number_scenes to something + big + + would -1 work for all frames? - add tests: load 1 page of a pdf/gif - load all frames from a pdf/gif + load all frames from a pdf/gif/dicom/tiff svg alpha density png alpha diff --git a/libvips/foreign/magick7load.c b/libvips/foreign/magick7load.c index ea9c595e..06e6968b 100644 --- a/libvips/foreign/magick7load.c +++ b/libvips/foreign/magick7load.c @@ -32,8 +32,8 @@ */ /* -#define DEBUG */ +#define DEBUG #ifdef HAVE_CONFIG_H #include @@ -409,7 +409,6 @@ vips_foreign_load_magick7_parse( VipsForeignLoadMagick7 *magick7, VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( magick7 ); const char *key; - Image *p; int i; #ifdef DEBUG @@ -540,19 +539,7 @@ vips_foreign_load_magick7_parse( VipsForeignLoadMagick7 *magick7, which says this is a volumetric image */ - magick7->n_frames = 0; - for( p = image; p; (p = GetNextImageInList( p )) ) { - if( p->columns != (unsigned int) out->Xsize || - p->rows != (unsigned int) out->Ysize || - GetPixelChannels( p ) != out->Bands ) - break; - - magick7->n_frames += 1; - } - if( p ) - /* Nope ... just do the first image in the list. - */ - magick7->n_frames = 1; + magick7->n_frames = GetImageListLength( GetFirstImageInList( image ) ); #ifdef DEBUG printf( "image has %d frames\n", magick7->n_frames ); diff --git a/test/images/cogs.gif b/test/images/cogs.gif new file mode 100644 index 00000000..8ded2e11 Binary files /dev/null and b/test/images/cogs.gif differ diff --git a/test/test_foreign.py b/test/test_foreign.py index 1397397e..7ead1d7f 100755 --- a/test/test_foreign.py +++ b/test/test_foreign.py @@ -52,6 +52,7 @@ class TestForeign(unittest.TestCase): self.svg_file = "images/vips-profile.svg" self.svgz_file = "images/vips-profile.svgz" self.svg_gz_file = "images/vips-profile.svg.gz" + self.gif_anim_file = "images/cogs.gif" self.colour = Vips.Image.jpegload(self.jpeg_file) self.mono = self.colour.extract_band(1) @@ -326,6 +327,21 @@ class TestForeign(unittest.TestCase): self.file_loader("magickload", self.gif_file, gif_valid) self.buffer_loader("magickload_buffer", self.gif_file, gif_valid) + # we should have rgba for svg files + im = Vips.Image.magickload(self.svg_file) + self.assertEqual(im.bands(), 4) + + # all-frames should load every frame of the animation + im = Vips.Image.magickload(self.gif_anim_file) + self.assertEqual(im.width(), 85) + self.assertEqual(im.height(), 77) + self.assertEqual(im.bands(), 4) + im = Vips.Image.magickload(self.gif_anim_file, all_frames = True) + self.assertEqual(im.width(), 85) + self.assertEqual(im.height(), 77 * 100) + self.assertEqual(im.bands(), 4) + + def test_webp(self): x = Vips.type_find("VipsForeign", "webpload") if not x.is_instantiatable():