only read webp bg in anim

non-anim webp does not use the background property

see https://github.com/libvips/libvips/issues/1261
This commit is contained in:
John Cupitt 2019-04-16 17:52:09 +01:00
parent bafc5775f0
commit ce24917d4a
1 changed files with 11 additions and 7 deletions

View File

@ -44,8 +44,8 @@
/*
#define DEBUG_VERBOSE
#define DEBUG
*/
#define DEBUG
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -421,12 +421,6 @@ read_header( Read *read, VipsImage *out )
flags = WebPDemuxGetI( read->demux, WEBP_FF_FORMAT_FLAGS );
/* background is in B, G, R, A byte order, but we need R, G, B, A for
* libvips.
*/
read->background = bgra2rgba(
WebPDemuxGetI( read->demux, WEBP_FF_BACKGROUND_COLOR ) );
read->alpha = flags & ALPHA_FLAG;
if( read->alpha )
read->config.output.colorspace = MODE_RGBA;
@ -441,6 +435,16 @@ read_header( Read *read, VipsImage *out )
read->frame_count = WebPDemuxGetI( read->demux,
WEBP_FF_FRAME_COUNT );
/* background is in B, G, R, A byte order, but we need
* R, G, B, A for libvips.
*
* background is only relevant for animations. For
* single-frame webp, we want to just return the RGBA in the
* file. We just leave bg as 0 and blend with that.
*/
read->background = bgra2rgba( WebPDemuxGetI( read->demux,
WEBP_FF_BACKGROUND_COLOR ) );
#ifdef DEBUG
printf( "webp2vips: animation\n" );
printf( "webp2vips: loop_count = %d\n", loop_count );