From 522734dd140a6449d0087fc7f81a1b5350f4e231 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Thu, 19 Sep 2019 17:54:44 +0800 Subject: [PATCH 1/9] swap width and height when source image orientation is left or right --- .../image_picker/ios/Classes/FLTImagePickerImageUtil.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m index 000bd4bf9c66..5ae72a0b8bba 100644 --- a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m +++ b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m @@ -76,6 +76,16 @@ + (UIImage *)scaledImage:(UIImage *)image scale:1 orientation:UIImageOrientationUp]; + // Swap width and height when source image orientation is left/right + 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)]; From 356033abceb9273481e328b51a56b6294d322821 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Thu, 19 Sep 2019 18:03:16 +0800 Subject: [PATCH 2/9] fix code style --- .../image_picker/ios/Classes/FLTImagePickerImageUtil.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m index 5ae72a0b8bba..4b8f4665690a 100644 --- a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m +++ b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m @@ -77,10 +77,10 @@ + (UIImage *)scaledImage:(UIImage *)image orientation:UIImageOrientationUp]; // Swap width and height when source image orientation is left/right - if([image imageOrientation] == UIImageOrientationLeft - || [image imageOrientation] == UIImageOrientationRight - || [image imageOrientation] == UIImageOrientationLeftMirrored - || [image imageOrientation] == UIImageOrientationRightMirrored) { + if ([image imageOrientation] == UIImageOrientationLeft || + [image imageOrientation] == UIImageOrientationRight || + [image imageOrientation] == UIImageOrientationLeftMirrored || + [image imageOrientation] == UIImageOrientationRightMirrored) { double temp = width; width = height; height = temp; From 0e058b0ba52ae8c5dea8324c91cabf68b14c26e6 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Sat, 12 Oct 2019 08:49:43 +0800 Subject: [PATCH 3/9] Add changelog information. Update pubspec version. --- packages/image_picker/CHANGELOG.md | 3 +++ packages/image_picker/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 78d44e594eb5..a9bc021543ab 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.1+5 +* iOS: Fix image orientation problems when scaling images. + ## 0.6.1+4 * Android: Fix a regression where the `retrieveLostImage` does not work anymore. diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index c5d1647bb410..ad09895d9445 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -5,7 +5,7 @@ authors: - Flutter Team - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.1+4 +version: 0.6.1+5 flutter: plugin: From ac6cdb051664aedf9513b6cb36227f33a2951608 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 11 Oct 2019 18:58:30 -0700 Subject: [PATCH 4/9] Update CHANGELOG.md --- packages/image_picker/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index a9bc021543ab..bba4c1408a0a 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,4 +1,5 @@ ## 0.6.1+5 + * iOS: Fix image orientation problems when scaling images. ## 0.6.1+4 From c00189d1a56ed033a5f6ef4dcf80132d68d4f0a9 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Sat, 12 Oct 2019 10:35:18 +0800 Subject: [PATCH 5/9] Change comments --- packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m index e98f05dbfe7d..71987988a9df 100644 --- a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m +++ b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m @@ -77,6 +77,8 @@ + (UIImage *)scaledImage:(UIImage *)image 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 || From 9e37930480a03f6ffd72ddc97949675b49bc1b20 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Tue, 15 Oct 2019 10:20:35 +0800 Subject: [PATCH 6/9] update annotation --- .../image_picker/ios/Classes/FLTImagePickerImageUtil.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m index 71987988a9df..6f9cfe80c6a2 100644 --- a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m +++ b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m @@ -76,9 +76,11 @@ + (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. + // The image orientation is manually set to UIImageOrientationUp which swapped the aspect ratio in some scenarios. + // For example, when the original image has orientation left, the horizontal pixels + // should be scaled to `width` and the vertical pixels should be scaled to `height`. After setting the orientation + // to up, we end up scaling the horizontal pixels to `height` and vertical to `width`. + // Below swap will solve this issue. if ([image imageOrientation] == UIImageOrientationLeft || [image imageOrientation] == UIImageOrientationRight || [image imageOrientation] == UIImageOrientationLeftMirrored || From 1783c2994ed1b439ce8ab4604cc89b23d37ba8bc Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Tue, 15 Oct 2019 10:27:59 +0800 Subject: [PATCH 7/9] fix format --- .../image_picker/ios/Classes/FLTImagePickerImageUtil.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m index 6f9cfe80c6a2..ab765208d0bc 100644 --- a/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m +++ b/packages/image_picker/ios/Classes/FLTImagePickerImageUtil.m @@ -76,11 +76,11 @@ + (UIImage *)scaledImage:(UIImage *)image scale:1 orientation:UIImageOrientationUp]; - // The image orientation is manually set to UIImageOrientationUp which swapped the aspect ratio in some scenarios. - // For example, when the original image has orientation left, the horizontal pixels - // should be scaled to `width` and the vertical pixels should be scaled to `height`. After setting the orientation - // to up, we end up scaling the horizontal pixels to `height` and vertical to `width`. - // Below swap will solve this issue. + // The image orientation is manually set to UIImageOrientationUp which swapped the aspect ratio in + // some scenarios. For example, when the original image has orientation left, the horizontal + // pixels should be scaled to `width` and the vertical pixels should be scaled to `height`. After + // setting the orientation to up, we end up scaling the horizontal pixels to `height` and vertical + // to `width`. Below swap will solve this issue. if ([image imageOrientation] == UIImageOrientationLeft || [image imageOrientation] == UIImageOrientationRight || [image imageOrientation] == UIImageOrientationLeftMirrored || From 4027f2c9a2257181483c0500bbc22c0289821718 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Thu, 17 Oct 2019 08:52:01 +0800 Subject: [PATCH 8/9] Update pubspec.yaml --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 6ad8153e66da..f3ed31d4d007 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -5,7 +5,7 @@ authors: - Flutter Team - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.1+8 +version: 0.6.1+9 flutter: plugin: From 1d7e8121fe2553f05d1d6986c61ebf5f6a617413 Mon Sep 17 00:00:00 2001 From: "junteng.zhang" Date: Tue, 29 Oct 2019 10:51:29 +0800 Subject: [PATCH 9/9] update pubspec version --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index f3ed31d4d007..93379d32fe7e 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -5,7 +5,7 @@ authors: - Flutter Team - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.1+9 +version: 0.6.1+10 flutter: plugin: