Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
4 changes: 4 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.1+7

* iOS: Fix image orientation problems when scaling images.

## 0.6.1+6

* Define clang module for iOS
Expand Down
12 changes: 12 additions & 0 deletions packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ + (UIImage *)scaledImage:(UIImage *)image
scale:1
orientation:UIImageOrientationUp];

// Swap width and height when source image orientation is left/right
// In order to avoid the problem of error width/height when image
// orientation in these enums.
if ([image imageOrientation] == UIImageOrientationLeft ||
[image imageOrientation] == UIImageOrientationRight ||
[image imageOrientation] == UIImageOrientationLeftMirrored ||
[image imageOrientation] == UIImageOrientationRightMirrored) {
double temp = width;
width = height;
height = temp;
}

UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0);
[imageToScale drawInRect:CGRectMake(0, 0, width, height)];

Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
- Flutter Team <[email protected]>
- Rhodes Davis Jr. <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
version: 0.6.1+6
version: 0.6.1+7

flutter:
plugin:
Expand Down