diff --git a/TODO b/TODO index 41db8d25..6956fe6e 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,3 @@ -- gif loader - - need tests, need to update APIs - - - - - could load pdf thumbnails? - new vips_reduce: diff --git a/cplusplus/include/vips/vips-operators.h b/cplusplus/include/vips/vips-operators.h index 9acf3962..7466fcc7 100644 --- a/cplusplus/include/vips/vips-operators.h +++ b/cplusplus/include/vips/vips-operators.h @@ -1,5 +1,5 @@ // headers for vips operations -// Tue Feb 9 10:43:17 GMT 2016 +// Fri Feb 12 20:04:03 GMT 2016 // this file is generated automatically, do not edit! static void system( char * cmd_format , VOption *options = 0 ); @@ -114,6 +114,8 @@ static VImage pdfload( char * filename , VOption *options = 0 ); static VImage pdfload_buffer( VipsBlob * buffer , VOption *options = 0 ); static VImage svgload( char * filename , VOption *options = 0 ); static VImage svgload_buffer( VipsBlob * buffer , VOption *options = 0 ); +static VImage gifload( char * filename , VOption *options = 0 ); +static VImage gifload_buffer( VipsBlob * buffer , VOption *options = 0 ); static VImage pngload( char * filename , VOption *options = 0 ); static VImage pngload_buffer( VipsBlob * buffer , VOption *options = 0 ); static VImage matload( char * filename , VOption *options = 0 ); diff --git a/cplusplus/vips-operators.cpp b/cplusplus/vips-operators.cpp index bc45cd90..257234ad 100644 --- a/cplusplus/vips-operators.cpp +++ b/cplusplus/vips-operators.cpp @@ -1,5 +1,5 @@ // bodies for vips operations -// Tue Feb 9 10:43:09 GMT 2016 +// Fri Feb 12 20:03:53 GMT 2016 // this file is generated automatically, do not edit! void VImage::system( char * cmd_format , VOption *options ) @@ -1456,6 +1456,30 @@ VImage VImage::svgload_buffer( VipsBlob * buffer , VOption *options ) return( out ); } +VImage VImage::gifload( char * filename , VOption *options ) +{ + VImage out; + + call( "gifload" , + (options ? options : VImage::option()) -> + set( "filename", filename ) -> + set( "out", &out ) ); + + return( out ); +} + +VImage VImage::gifload_buffer( VipsBlob * buffer , VOption *options ) +{ + VImage out; + + call( "gifload_buffer" , + (options ? options : VImage::option()) -> + set( "buffer", buffer ) -> + set( "out", &out ) ); + + return( out ); +} + VImage VImage::pngload( char * filename , VOption *options ) { VImage out; diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 3abad720..fca634cd 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -508,6 +508,7 @@ vips_foreign_load_gif_buffer_read( GifFileType *file, size_t will_read = VIPS_MIN( len, buffer->bytes_to_go ); memcpy( buf, buffer->p, will_read ); + buffer->p += will_read; buffer->bytes_to_go -= will_read; return( will_read ); diff --git a/python/Vips.py b/python/Vips.py index 05e5be23..ecde983f 100644 --- a/python/Vips.py +++ b/python/Vips.py @@ -1097,6 +1097,8 @@ class_methods = [ "pdfload_buffer", "svgload", "svgload_buffer", + "gifload", + "gifload_buffer", "openslideload", "magickload", "magickload_buffer", diff --git a/test/images/trans-x.gif b/test/images/trans-x.gif new file mode 100644 index 00000000..6dab62da Binary files /dev/null and b/test/images/trans-x.gif differ diff --git a/test/test_foreign.py b/test/test_foreign.py index f0f58fdf..d1467c4a 100755 --- a/test/test_foreign.py +++ b/test/test_foreign.py @@ -365,6 +365,22 @@ class TestForeign(unittest.TestCase): self.assertLess(abs(im.width * 2 - x.width), 2) self.assertLess(abs(im.height * 2 - x.height), 2) + def test_gifload(self): + x = Vips.type_find("VipsForeign", "gifload") + if not x.is_instantiatable(): + print("no gif support in this vips, skipping test") + return + + def gif_valid(self, im): + a = im(10, 10) + self.assertAlmostEqualObjects(a, [33, 33, 33, 255]) + self.assertEqual(im.width, 159) + self.assertEqual(im.height, 203) + self.assertEqual(im.bands, 4) + + self.file_loader("gifload", self.gif_file, gif_valid) + self.buffer_loader("gifload_buffer", self.gif_file, gif_valid) + def test_svgload(self): x = Vips.type_find("VipsForeign", "svgload") if not x.is_instantiatable():