Skip to content

Commit c1a684a

Browse files
committed
Do not apply EXIF orientation transform because libjxl already applied
1 parent 89126a9 commit c1a684a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

SDWebImageJPEGXLCoder/Classes/SDImageJPEGXLCoder.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ __strong void(^cleanupBlock)(void) __attribute__((cleanup(sd_executeCleanupBlock
177177
JxlBasicInfo info;
178178
status = JxlDecoderGetBasicInfo(dec, &info);
179179
if (status != JXL_DEC_SUCCESS) return nil;
180-
CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)info.orientation;
180+
// By defaults, libjxl applys transform for orientation, unless we call `JxlDecoderSetKeepOrientation`
181+
// CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)info.orientation;
181182

182183
// colorspace
183184
size_t profileSize;
@@ -212,10 +213,9 @@ __strong void(^cleanupBlock)(void) __attribute__((cleanup(sd_executeCleanupBlock
212213
return nil;
213214
}
214215
#if SD_MAC
215-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:exifOrientation];
216+
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:kCGImagePropertyOrientationUp];
216217
#else
217-
UIImageOrientation orientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:exifOrientation];
218-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:orientation];
218+
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
219219
#endif
220220
CGImageRelease(imageRef);
221221

@@ -237,10 +237,9 @@ __strong void(^cleanupBlock)(void) __attribute__((cleanup(sd_executeCleanupBlock
237237
CGImageRef imageRef = [self sd_createJXLImageWithDec:dec info:info colorSpace:colorSpaceRef thumbnailSize:thumbnailSize preserveAspectRatio:preserveAspectRatio];
238238
if (!imageRef) continue;
239239
#if SD_MAC
240-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:exifOrientation];
240+
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:kCGImagePropertyOrientationUp];
241241
#else
242-
UIImageOrientation orientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:exifOrientation];
243-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:orientation];
242+
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
244243
#endif
245244
CGImageRelease(imageRef);
246245

0 commit comments

Comments
 (0)