From 8c05a2bbe81ce453746403894972ea1bc12ab9a0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 4 Aug 2016 15:55:06 +0100 Subject: [PATCH] argh all_frames doesn't work for gif --- TODO | 8 +++++++- libvips/foreign/magick7load.c | 17 ++--------------- test/images/cogs.gif | Bin 0 -> 2759 bytes test/test_foreign.py | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 test/images/cogs.gif 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 0000000000000000000000000000000000000000..8ded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ga&V z{vz<;5fVcbt|8PSHETWKnZImXkuRD`4;DQ8{dx8>EG8x{9?FS{q=2cM3{n;?-O`#9 zXP@Yqnvad~Oi9z^B1$aIGOJZ;{A+jD(X@FJ{ z$>Q1XDM`(KD>9put24N_2uhKaVPh#=$kO{`cZQ@9{r+w zL%Xb9lv1OVo{@IMI+ciyl$SvRG>{6S8F+FqAf^fijpb$JWgxm=7uIWjqXn2~adkQ!Bw>i+ zYD_#MWW6MULZ≪Xw>Mg$#Is3;;)?kgV4z;KZO1kQ52H;mKGgg%(N&oXA09at~v7 zW5Axm0?bWK*+odMFsNCZfuuc;J&xHVV*s~jTU0mV4N z9Yx0MHa6Y339b=`I7?1lmyy+VXfqI*LhoS!k@A(dk7sb>_n PEc*==lbEl=5SxDiavr_; literal 0 HcmV?d00001 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():