-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] Image picker fix metadata #3873
Changes from 5 commits
006c665
936ff6b
d02c78a
cbcc751
10d2920
74c64ae
eb07255
d28036b
570603a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,8 @@ NS_ASSUME_NONNULL_BEGIN | |
|
|
||
| + (UIImage *)scaledImage:(UIImage *)image | ||
| maxWidth:(NSNumber *)maxWidth | ||
| maxHeight:(NSNumber *)maxHeight; | ||
| maxHeight:(NSNumber *)maxHeight | ||
| metadataAvailability:(BOOL)metadataAvailability; | ||
|
||
|
|
||
| // Resize all gif animation frames. | ||
| + (GIFInfo *)scaledGIFImage:(NSData *)data | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,15 +367,17 @@ - (void)picker:(PHPickerViewController *)picker | |
| if (image != nil) { | ||
| __block UIImage *localImage = image; | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| localImage = [FLTImagePickerImageUtil scaledImage:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight]; | ||
| } | ||
|
|
||
| PHAsset *originalAsset = | ||
| [FLTImagePickerPhotoAssetUtil getAssetFromPHPickerResult:result]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| localImage = | ||
| [FLTImagePickerImageUtil scaledImage:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| metadataAvailability:originalAsset == nil ? NO : YES]; | ||
|
||
| } | ||
|
|
||
| if (!originalAsset) { | ||
| // Image picked without an original asset (e.g. User took a photo directly) | ||
| [self saveImageWithPickerInfo:nil | ||
|
|
@@ -449,11 +451,15 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
| NSNumber *imageQuality = [_arguments objectForKey:@"imageQuality"]; | ||
| NSNumber *desiredImageQuality = [self getDesiredImageQuality:imageQuality]; | ||
|
|
||
| PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| image = [FLTImagePickerImageUtil scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; | ||
| image = [FLTImagePickerImageUtil scaledImage:image | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| metadataAvailability:originalAsset == nil ? NO : YES]; | ||
| } | ||
|
|
||
| PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
| if (!originalAsset) { | ||
| // Image picked without an original asset (e.g. User took a photo directly) | ||
| [self saveImageWithPickerInfo:info image:image imageQuality:desiredImageQuality]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,10 @@ @implementation ImageUtilTests | |
|
|
||
| - (void)testScaledImage_ShouldBeScaled { | ||
| UIImage *image = [UIImage imageWithData:ImagePickerTestImages.JPGTestData]; | ||
| UIImage *newImage = [FLTImagePickerImageUtil scaledImage:image maxWidth:@3 maxHeight:@2]; | ||
| UIImage *newImage = [FLTImagePickerImageUtil scaledImage:image | ||
| maxWidth:@3 | ||
| maxHeight:@2 | ||
| metadataAvailability:YES]; | ||
|
||
|
|
||
| XCTAssertEqual(newImage.size.width, 3); | ||
| XCTAssertEqual(newImage.size.height, 2); | ||
|
|
||
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.
Since there's no publish API change, it should be 0.7.5+1
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.
done.