diff --git a/SDWebImage/Core/SDImageIOCoder.m b/SDWebImage/Core/SDImageIOCoder.m index 1c0fbfa0..42f70846 100644 --- a/SDWebImage/Core/SDImageIOCoder.m +++ b/SDWebImage/Core/SDImageIOCoder.m @@ -132,8 +132,13 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination } } decodingOptions = @{ + // This option will cause ImageIO return the pixel size from `CGImageSourceCopyProperties` + // If not provided, it always return 0 size kSDCGImageSourceRasterizationDPI : @(rasterizationDPI), }; + // Already calculated DPI, avoid re-calculation based on thumbnail information + preserveAspectRatio = YES; + thumbnailSize = CGSizeZero; } UIImage *image = [SDImageIOAnimatedCoder createFrameAtIndex:0 source:source scale:scale preserveAspectRatio:preserveAspectRatio thumbnailSize:thumbnailSize options:decodingOptions];