Remove the extra calculation of image orientation for ImageIO coder
This commit is contained in:
parent
fa59de5f76
commit
b9ec481edf
|
@ -90,20 +90,7 @@
|
|||
}
|
||||
|
||||
UIImage *image = [[UIImage alloc] initWithData:data scale:scale];
|
||||
#if SD_MAC
|
||||
return image;
|
||||
#else
|
||||
if (!image) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIImageOrientation orientation = [[self class] sd_imageOrientationFromImageData:data];
|
||||
if (orientation != UIImageOrientationUp) {
|
||||
image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:orientation];
|
||||
}
|
||||
|
||||
return image;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - Progressive Decode
|
||||
|
@ -314,27 +301,4 @@
|
|||
return canEncode;
|
||||
}
|
||||
|
||||
#if SD_UIKIT || SD_WATCH
|
||||
#pragma mark EXIF orientation tag converter
|
||||
+ (UIImageOrientation)sd_imageOrientationFromImageData:(nonnull NSData *)imageData {
|
||||
UIImageOrientation result = UIImageOrientationUp;
|
||||
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
|
||||
if (imageSource) {
|
||||
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
|
||||
if (properties) {
|
||||
CFTypeRef val;
|
||||
NSInteger exifOrientation;
|
||||
val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
|
||||
if (val) {
|
||||
CFNumberGetValue(val, kCFNumberNSIntegerType, &exifOrientation);
|
||||
result = [SDWebImageCoderHelper imageOrientationFromEXIFOrientation:(CGImagePropertyOrientation)exifOrientation];
|
||||
} // else - if it's not set it remains at up
|
||||
CFRelease((CFTypeRef) properties);
|
||||
}
|
||||
CFRelease(imageSource);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
@ -87,20 +87,6 @@
|
|||
expect(decodedImage.size.width).to.equal(image.size.width);
|
||||
expect(decodedImage.size.height).to.equal(image.size.height);
|
||||
}
|
||||
|
||||
- (void)test08ImageOrientationFromImageDataWithInvalidData {
|
||||
// sync download image
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wundeclared-selector"
|
||||
SEL selector = @selector(sd_imageOrientationFromImageData:);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
UIImageOrientation orientation = (UIImageOrientation)[[SDWebImageImageIOCoder class] performSelector:selector withObject:nil];
|
||||
#pragma clang diagnostic pop
|
||||
expect(orientation).to.equal(UIImageOrientationUp);
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)test09ThatStaticWebPCoderWorks {
|
||||
|
|
Loading…
Reference in New Issue