-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] Fix ios scaling in portrait mode #2061
Conversation
|
@Xavjer Can we just flip the width and height for portrait pictures instead of using a completely different API? This change may be a bit risky until we set up a CI and write tests for this. |
|
@cyanglaz I was thinking about that too, but from my understanding this is the better way to create a thumbnail, as the resulting image has a better resolution (and memory/performance improvement, especially during the case that we have to rotate the image) and it get's rid of the "issue" to rotate the image first. This is apple's recommended way, see: https://medium.com/@prafullkumar77/image-usage-memory-comparison-and-best-practices-in-ios-wwdc2018-4a8919019ae9 Your fix should work too, but I was trying to improve the code itself not only fix the issue. |
| CFDictionaryRef options = (__bridge CFDictionaryRef) @{ | ||
| (id)kCGImageSourceCreateThumbnailWithTransform : @YES, | ||
| (id)kCGImageSourceCreateThumbnailFromImageAlways : @YES, | ||
| (id)kCGImageSourceThumbnailMaxPixelSize : MAX(maxWidth, maxHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the behavior would be different here.
Imagine we have an image that we want to specify maxWidth to be 100 and height to be 400. The original image is very big say 2000 by 4000.
In our old implementation, the final image would be 100 * 200.
In this implementation, the final image would be 400 * 800.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, that would happen in this solution. There is only a maxDimension which can be set with this, therefore your recommended way will probably be the correct solution. For my usecase, I want to reduce the imagesize for the larger side to be 1024, therefore that worked for my case.
|
Closing this PR and we will solve the issue with #2070 |
Description
Fixes the issue, that within image_picker when taking a picture on iOS in Portrait mode, the scaling did not work as intended (AspectRatio was flipped)
Related Issues
flutter/flutter#40334 => Will be fixed with this PR
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.=> No new unit tests added, as the existing should already cover this, but the image did not have the values that were returned from the channel.
///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?