From 34ec3b7bf1b70389bc435603efa78da3d07cc5f6 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Fri, 15 May 2020 11:02:05 +0800 Subject: [PATCH] Fix the issue that ImageIO max pixel size larger than image size will cause a upscale. This is not the documented behavior --- SDWebImage/Core/SDImageIOCoder.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/Core/SDImageIOCoder.m b/SDWebImage/Core/SDImageIOCoder.m index 11565e12..715b0205 100644 --- a/SDWebImage/Core/SDImageIOCoder.m +++ b/SDWebImage/Core/SDImageIOCoder.m @@ -277,7 +277,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination } NSUInteger pixelWidth = CGImageGetWidth(imageRef); NSUInteger pixelHeight = CGImageGetHeight(imageRef); - if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > 0 && pixelHeight > 0) { + if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > maxPixelSize.width && pixelHeight > maxPixelSize.height) { CGFloat pixelRatio = pixelWidth / pixelHeight; CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height; CGFloat finalPixelSize;