Remove the extra calculation of image orientation for ImageIO coder
This commit is contained in:
parent
22e532c9e3
commit
c6fa6e31fb
|
@ -98,20 +98,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
|||
|
||||
UIImage *image = [[UIImage alloc] initWithData:data];
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
- (UIImage *)incrementallyDecodedImageWithData:(NSData *)data finished:(BOOL)finished {
|
||||
|
@ -516,31 +503,6 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
|||
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:exifOrientation];
|
||||
} // else - if it's not set it remains at up
|
||||
CFRelease((CFTypeRef) properties);
|
||||
} else {
|
||||
//NSLog(@"NO PROPERTIES, FAIL");
|
||||
}
|
||||
CFRelease(imageSource);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SD_UIKIT || SD_WATCH
|
||||
+ (BOOL)shouldScaleDownImage:(nonnull UIImage *)image {
|
||||
BOOL shouldScaleDown = YES;
|
||||
|
|
|
@ -82,20 +82,6 @@
|
|||
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);
|
||||
}
|
||||
|
||||
- (void)test09ThatStaticWebPCoderWorks {
|
||||
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
|
||||
[self verifyCoder:[SDWebImageWebPCoder sharedCoder]
|
||||
|
|
Loading…
Reference in New Issue