From 01b66f5ccd6e1c6f6fbcaae2ccf9353de6b60f39 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 13 Aug 2018 17:30:54 +0100 Subject: [PATCH] clear gif pages before load some gifs may not clear the background, so we must init pages as 0 see https://github.com/lovell/sharp/issues/1331 --- libvips/foreign/gifload.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 4860a66e..60c6af57 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -18,6 +18,8 @@ * 21/11/17 * - add "gif-delay", "gif-loop", "gif-comment" metadata * - add dispose handling + * 13/8/18 + * - init pages to 0 before load */ /* @@ -779,6 +781,13 @@ vips_foreign_load_gif_new_page( VipsForeignLoadGif *gif ) return( NULL ); } + /* Some GIFs may not clear the background, so we must start + * transparent. + */ + memset( VIPS_IMAGE_ADDR( out, 0, 0 ), + 0, + VIPS_IMAGE_SIZEOF_IMAGE( out ) ); + return( out ); }