From f91d35ef8d703a861644d7c406e717a6b21ae112 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 13 Jul 2022 16:04:29 +0800 Subject: [PATCH] Fix the PDF image without thumbnailPixelSize will result huge bitmap size, now fixed into 72 DPI matching PDFKit --- SDWebImage/Core/SDImageIOAnimatedCoder.m | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/SDWebImage/Core/SDImageIOAnimatedCoder.m b/SDWebImage/Core/SDImageIOAnimatedCoder.m index 22c050d5..9ed55b2c 100644 --- a/SDWebImage/Core/SDImageIOAnimatedCoder.m +++ b/SDWebImage/Core/SDImageIOAnimatedCoder.m @@ -215,19 +215,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination BOOL createFullImage = thumbnailSize.width == 0 || thumbnailSize.height == 0 || pixelWidth == 0 || pixelHeight == 0 || (pixelWidth <= thumbnailSize.width && pixelHeight <= thumbnailSize.height); if (createFullImage) { if (isVector) { - if (thumbnailSize.width == 0 || thumbnailSize.height == 0) { - // Provide the default pixel count for vector images, simply just use the screen size -#if SD_WATCH - thumbnailSize = WKInterfaceDevice.currentDevice.screenBounds.size; -#elif SD_UIKIT - thumbnailSize = UIScreen.mainScreen.bounds.size; -#elif SD_MAC - thumbnailSize = NSScreen.mainScreen.frame.size; -#endif - } - CGFloat maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.height); - NSUInteger DPIPerPixel = 2; - NSUInteger rasterizationDPI = maxPixelSize * DPIPerPixel; + // Use 72 DPI by default, matching Apple's PDFKit behavior + NSUInteger rasterizationDPI = 72; decodingOptions[kSDCGImageSourceRasterizationDPI] = @(rasterizationDPI); } imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);