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

[iOS] Fix compression resize resulting in blank image #2075

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markholland
Copy link

Fixes #2074

@markholland markholland changed the title [iOS] Fix compress size larger than 2049 resulting in blank image [iOS] Fix compression resize resulting in blank image Jul 19, 2024
@sasha-maliauka
Copy link

Hey Mark! Thanks for submitting your solution. There's a small tweak that I noticed - you need to pass the created format to the UIGraphicsImageRenderer:

UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize format:format];

That way it works for me.

@@ -53,6 +53,8 @@ - (ImageResult*) compressImageDimensions:(UIImage*)image
}
CGSize newSize = CGSizeMake(newWidth, newHeight);

UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat new];
format.scale = 1;
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize];

Choose a reason for hiding this comment

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

Suggested change
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize];
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize format:format];

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, must have been asleep at the wheel that day. Glad it helped you.

@Lakston
Copy link

Lakston commented Sep 18, 2024

Is this going to be merged soon ?

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.

[iOS] Blank image returned when compress size above certain value
3 participants