Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image scale issue in thumbnail creation #793

Merged
merged 2 commits into from
Jul 13, 2024
Merged

Conversation

prabhuamol
Copy link

@prabhuamol prabhuamol commented Jun 21, 2024

Potential fix for #791 Also makes sure resized images have the same orientation as the original image

Also renamed the image which was right oriented correctly

@prabhuamol prabhuamol mentioned this pull request Jun 21, 2024
@@ -52,7 +52,9 @@ extension ImageDecoders {

func makeImage() -> PlatformImage? {
if let thumbnail {
return makeThumbnail(data: data, options: thumbnail)
return makeThumbnail(data: data,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use scale in creating a thumbnail similar to how ImageDecoders.Default._decode(data, scale: scale) is using it below

more tests

use scale

make scale non optional

docs
@@ -366,7 +383,22 @@ func makeThumbnail(data: Data, options: ImageRequest.ThumbnailOptions) -> Platfo
guard let image = CGImageSourceCreateThumbnailAtIndex(source, 0, options as CFDictionary) else {
return nil
}

#if canImport(UIKit)
let orientation: UIImage.Orientation
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed to make sure the returned image has the same orientation as the original. Verified via tests below with .right and .up orientation images

@prabhuamol prabhuamol changed the title Fix image scale issue with Nuke Fix image scale issue in thumbnail creation Jul 10, 2024
@kean
Copy link
Owner

kean commented Jul 13, 2024

Hey, thanks @prabhuamol. I think it looks really good now.

@kean
Copy link
Owner

kean commented Jul 13, 2024

I will update the tests in main.

@kean kean merged commit 97e1908 into kean:main Jul 13, 2024
5 of 8 checks passed
@prabhuamol prabhuamol deleted the imagescale branch July 13, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants