Fix the thumbnail pixel size calculation when preserveAspectRatio is true
This commit is contained in:
parent
91c9966d77
commit
f90373ce14
|
@ -238,9 +238,9 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
||||
CGFloat thumbnailRatio = thumbnailSize.width / thumbnailSize.height;
|
||||
if (pixelRatio > thumbnailRatio) {
|
||||
maxPixelSize = thumbnailSize.width;
|
||||
maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.width / pixelRatio);
|
||||
} else {
|
||||
maxPixelSize = thumbnailSize.height;
|
||||
maxPixelSize = MAX(thumbnailSize.height, thumbnailSize.height * pixelRatio);
|
||||
}
|
||||
} else {
|
||||
maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.height);
|
||||
|
@ -503,9 +503,9 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
||||
CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height;
|
||||
if (pixelRatio > maxPixelSizeRatio) {
|
||||
finalPixelSize = maxPixelSize.width;
|
||||
finalPixelSize = MAX(maxPixelSize.width, maxPixelSize.width / pixelRatio);
|
||||
} else {
|
||||
finalPixelSize = maxPixelSize.height;
|
||||
finalPixelSize = MAX(maxPixelSize.height, maxPixelSize.height * pixelRatio);
|
||||
}
|
||||
properties[(__bridge NSString *)kCGImageDestinationImageMaxPixelSize] = @(finalPixelSize);
|
||||
}
|
||||
|
|
|
@ -257,9 +257,9 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height;
|
||||
CGFloat finalPixelSize;
|
||||
if (pixelRatio > maxPixelSizeRatio) {
|
||||
finalPixelSize = maxPixelSize.width;
|
||||
finalPixelSize = MAX(maxPixelSize.width, maxPixelSize.width / pixelRatio);
|
||||
} else {
|
||||
finalPixelSize = maxPixelSize.height;
|
||||
finalPixelSize = MAX(maxPixelSize.height, maxPixelSize.height * pixelRatio);
|
||||
}
|
||||
properties[(__bridge NSString *)kCGImageDestinationImageMaxPixelSize] = @(finalPixelSize);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue