From 6f0548dc5c272f02481f0a201bbf086cc1152b15 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 21 Apr 2020 10:15:02 +0100 Subject: [PATCH] thumbnail could fail on HEIC in some modes in locked UP or DOWN mode, vips_thumbnail() could incorrectly select the thumbnail from a HEIC image even when it was not large enough to generate the output image. Thanks ZorinArsenij See https://github.com/libvips/libvips/issues/1614 --- ChangeLog | 2 ++ libvips/resample/thumbnail.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ba570eb..494cb001 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - add fuzz corpus to dist - detect read errors correctly in source_sniff - fix regression in autorot [malomalo] +- thumbnail on HEIC images could select the thumbnail incorrectly under some + size modes [ZorinArsenij] 20/6/19 started 8.9.1 - don't use the new source loaders for new_from_file or new_from_buffer, it diff --git a/libvips/resample/thumbnail.c b/libvips/resample/thumbnail.c index dd282bc6..b4711da4 100644 --- a/libvips/resample/thumbnail.c +++ b/libvips/resample/thumbnail.c @@ -495,15 +495,18 @@ vips_thumbnail_open( VipsThumbnail *thumbnail ) /* 'factor' is a gboolean which enables thumbnail load instead * of image load. * - * Use the thumbnail if, by using it, we could get a factor >= - * 1.0, ie. we would not need to expand the thumbnail. + * Use the thumbnail if, by using it, we could get a factor > + * 1.0, ie. we would not need to expand the thumbnail. + * + * Don't use >= since factor can be clipped to 1.0 under some + * resizing modes. */ double shrink_factor = vips_thumbnail_calculate_common_shrink( thumbnail, thumbnail->heif_thumbnail_width, thumbnail->heif_thumbnail_height ); - factor = shrink_factor >= 1.0 ? 1 : 0; + factor = shrink_factor > 1.0 ? 1 : 0; } g_info( "loading with factor %g pre-shrink", factor );