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:
parent
670d109a67
commit
bafc5775f0
@ -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" ) );
|
||||
|
@ -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 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user