fix ms/cs mixup in webp load/save

there was a mixup between milliseconds (what webp uses for timestamps)
and centiseconds (what gif uses for delay times)
This commit is contained in:
John Cupitt 2019-04-16 17:12:57 +01:00
parent 670d109a67
commit bafc5775f0
2 changed files with 7 additions and 12 deletions

View File

@ -292,9 +292,10 @@ get_int( VipsImage *image, const char *field, int default_value )
static int
write_webp_anim( VipsWebPWrite *write, VipsImage *image, int page_height )
{
/* 100ms is the webp default.
/* 100ms is the webp default. gif-delay is in centiseconds (the GIF
* standard).
*/
const int delay = get_int( image, "gif-delay", 100 );
const int delay = 10 * get_int( image, "gif-delay", 10 );
WebPAnimEncoderOptions anim_config;
WebPData webp_data;
@ -348,15 +349,6 @@ write_webp_anim( VipsWebPWrite *write, VipsImage *image, int page_height )
timestamp_ms += delay;
}
/* Add a last zero length fake frame to signal the last duration.
*/
if( !WebPAnimEncoderAdd( write->enc,
NULL, timestamp_ms - delay, NULL ) ) {
vips_error( "vips2webp",
"%s", _( "anim build error" ) );
return( -1 );
}
if( !WebPAnimEncoderAssemble( write->enc, &webp_data ) ) {
vips_error( "vips2webp",
"%s", _( "anim build error" ) );

View File

@ -460,7 +460,10 @@ read_header( Read *read, VipsImage *out )
printf( "webp2vips: duration = %d\n", read->delay );
#endif /*DEBUG*/
vips_image_set_int( out, "gif-delay", read->delay );
/* webp uses ms for delays, gif uses centiseconds.
*/
vips_image_set_int( out, "gif-delay",
VIPS_RINT( read->delay / 10.0 ) );
}
WebPDemuxReleaseIterator( &iter );