From c2be771342bdd39fedea1a52eec7d0df387724ff Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 12 Feb 2016 20:04:46 +0000 Subject: [PATCH] fix load from buffer, update APIs --- TODO | 7 ------- cplusplus/include/vips/vips-operators.h | 4 +++- cplusplus/vips-operators.cpp | 26 +++++++++++++++++++++++- libvips/foreign/gifload.c | 1 + python/Vips.py | 2 ++ test/images/trans-x.gif | Bin 0 -> 1113 bytes test/test_foreign.py | 16 +++++++++++++++ 7 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 test/images/trans-x.gif 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 0000000000000000000000000000000000000000..6dab62da841906250367cbd3b2403172f0812b2b GIT binary patch literal 1113 zcmcgr+e_485FH^wq#H>XxRq8Ch)6IHMiD~Lsi1@3agMCWvgtIMVXZeNJ>`8D2Wm) zAptg^frVjoliTCMSS!}DwdB?!GsYURhOHsT0!1-a#0py>M+&`cEQ@8fOyG!7OU9B| zVoTTx)&K)(ummmCuo&2Y1{Q|N3353?jA3KQ>BCxNB1YHe=Cr;3;%S9%*+IkB0;Hpz$1VC71_I-YV}U z{`a4hshNSo;O^w3MThn#`*Q*tDdqRHn0PQs$A|w&kh0>YC??LA9jbX+9+!}o-yN!b zc6#>W+^Xz*H(s2X$HgDI@6~mkO-?LG%Bfh=S&_1Nb$ZXQ%HGSfx5Sqe&AA!5G`;9u zbI*hNf$Lf2@$++=8(!6ApHJJ~d!fGn+@b@^t0xbQ^xsOl-uC?1rje(O`DMk!#fNXd z3GE$h+}_u6=Y8w`&%M>_TJH|G$46fK8WMkO3oYIBDK`I7dcjGVpV*F=k^n2>5=&A*iZ~OK{>a}rh d#*wd2W<;;$g**QKnVcAl4ur$1S+Ub-