Authored by DreamPiggy

Remove the extra calculation of image orientation for ImageIO coder

@@ -98,20 +98,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over @@ -98,20 +98,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
98 98
99 UIImage *image = [[UIImage alloc] initWithData:data]; 99 UIImage *image = [[UIImage alloc] initWithData:data];
100 100
101 -#if SD_MAC  
102 return image; 101 return image;
103 -#else  
104 - if (!image) {  
105 - return nil;  
106 - }  
107 -  
108 - UIImageOrientation orientation = [[self class] sd_imageOrientationFromImageData:data];  
109 - if (orientation != UIImageOrientationUp) {  
110 - image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:orientation];  
111 - }  
112 -  
113 - return image;  
114 -#endif  
115 } 102 }
116 103
117 - (UIImage *)incrementallyDecodedImageWithData:(NSData *)data finished:(BOOL)finished { 104 - (UIImage *)incrementallyDecodedImageWithData:(NSData *)data finished:(BOOL)finished {
@@ -517,31 +504,6 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over @@ -517,31 +504,6 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
517 } 504 }
518 505
519 #if SD_UIKIT || SD_WATCH 506 #if SD_UIKIT || SD_WATCH
520 -#pragma mark EXIF orientation tag converter  
521 -+ (UIImageOrientation)sd_imageOrientationFromImageData:(nonnull NSData *)imageData {  
522 - UIImageOrientation result = UIImageOrientationUp;  
523 - CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);  
524 - if (imageSource) {  
525 - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);  
526 - if (properties) {  
527 - CFTypeRef val;  
528 - NSInteger exifOrientation;  
529 - val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);  
530 - if (val) {  
531 - CFNumberGetValue(val, kCFNumberNSIntegerType, &exifOrientation);  
532 - result = [SDWebImageCoderHelper imageOrientationFromEXIFOrientation:exifOrientation];  
533 - } // else - if it's not set it remains at up  
534 - CFRelease((CFTypeRef) properties);  
535 - } else {  
536 - //NSLog(@"NO PROPERTIES, FAIL");  
537 - }  
538 - CFRelease(imageSource);  
539 - }  
540 - return result;  
541 -}  
542 -#endif  
543 -  
544 -#if SD_UIKIT || SD_WATCH  
545 + (BOOL)shouldScaleDownImage:(nonnull UIImage *)image { 507 + (BOOL)shouldScaleDownImage:(nonnull UIImage *)image {
546 BOOL shouldScaleDown = YES; 508 BOOL shouldScaleDown = YES;
547 509
@@ -82,20 +82,6 @@ @@ -82,20 +82,6 @@
82 expect(decodedImage.size.height).to.equal(image.size.height); 82 expect(decodedImage.size.height).to.equal(image.size.height);
83 } 83 }
84 84
85 -- (void)test08ImageOrientationFromImageDataWithInvalidData {  
86 - // sync download image  
87 -#pragma clang diagnostic push  
88 -#pragma clang diagnostic ignored "-Wundeclared-selector"  
89 - SEL selector = @selector(sd_imageOrientationFromImageData:);  
90 -#pragma clang diagnostic pop  
91 -  
92 -#pragma clang diagnostic push  
93 -#pragma clang diagnostic ignored "-Warc-performSelector-leaks"  
94 - UIImageOrientation orientation = (UIImageOrientation)[[SDWebImageImageIOCoder class] performSelector:selector withObject:nil];  
95 -#pragma clang diagnostic pop  
96 - expect(orientation).to.equal(UIImageOrientationUp);  
97 -}  
98 -  
99 - (void)test09ThatStaticWebPCoderWorks { 85 - (void)test09ThatStaticWebPCoderWorks {
100 NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"]; 86 NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
101 [self verifyCoder:[SDWebImageWebPCoder sharedCoder] 87 [self verifyCoder:[SDWebImageWebPCoder sharedCoder]