-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker]fix load error when the image is BMP/HEIF/HEIC format #4665
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@xiaoxiaowesley Thanks preparing this PR! This PR will need tests to move forward :) |
Thanks for the submission! In the future, please do not delete the checklist that is in the PR template; it is there for a reason. This PR is missing required elements described in the checklist (I’ve restored it to the PR description), which need to be addressed before it moves forward with review. If you have any questions about completing those steps that aren’t addressed documentation, please let me know. |
It looks like this will collide with #4448, so it would make sense to land that first then re-evaluate here. |
OK. This is my first PR to Plugins.No quite sure about the rule. Thank you for letting me know. |
Status from PR review: Still blocked on #4448, but that one is close. |
#4448 has landed, so you can update this against the latest trunk and address the remaining items in the PR checklist, then we can review. |
Great.On my way |
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@stuartmorgan hi, I had added tests, and the checks all passed but remain one failed. |
|
@cyanglaz hi, It seems no problem now. Would you help me to review it? |
if (error == nil) { | ||
__block UIImage *localImage = | ||
[[UIImage alloc] initWithData:data]; | ||
PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil | ||
getAssetFromPHPickerResult:self.result]; | ||
|
||
if (self.maxWidth != (id)[NSNull null] || | ||
self.maxHeight != (id)[NSNull null]) { | ||
localImage = [FLTImagePickerImageUtil | ||
scaledImage:localImage | ||
maxWidth:self.maxWidth | ||
maxHeight:self.maxHeight | ||
isMetadataAvailable:originalAsset != nil]; | ||
} | ||
__block NSString *savedPath; | ||
if (!originalAsset) { | ||
// Image picked without an original asset (e.g. User pick | ||
// image without permission) | ||
savedPath = [FLTImagePickerPhotoAssetUtil | ||
saveImageWithPickerInfo:nil | ||
image:localImage | ||
imageQuality:self.desiredImageQuality]; | ||
[self completeOperationWithPath:savedPath]; | ||
} else { | ||
[[PHImageManager defaultManager] | ||
requestImageDataForAsset:originalAsset | ||
options:nil | ||
resultHandler:^( | ||
NSData *_Nullable imageData, | ||
NSString *_Nullable dataUTI, | ||
UIImageOrientation orientation, | ||
NSDictionary *_Nullable info) { | ||
// maxWidth and maxHeight are used only for | ||
// GIF images. | ||
savedPath = [FLTImagePickerPhotoAssetUtil | ||
saveImageWithOriginalImageData: | ||
imageData | ||
image: | ||
localImage | ||
maxWidth: | ||
self.maxWidth | ||
maxHeight: | ||
self.maxHeight | ||
imageQuality: | ||
self.desiredImageQuality]; | ||
[self completeOperationWithPath:savedPath]; | ||
}]; | ||
} | ||
} else { | ||
[self completeOperationWithPath:nil]; | ||
} |
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.
Can this be replaced wtih [self processImage:image];
?
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.
ok。I modified it.
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.
LGTM % nits.
@stuartmorgan as a second reviewer.
packages/image_picker/image_picker/ios/Classes/FLTPHPickerSaveImageToPathOperation.m
Outdated
Show resolved
Hide resolved
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'll need to update this for the federation of the iOS implementation, but it should be straightforward; all the changes just need to be to image_picker_ios
instead.
|
||
## 0.8.4+12 | ||
|
||
* iOS:support images with heic,heif,raw,tiff formats. |
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.
* iOS:support images with heic,heif,raw,tiff formats. | |
* Adds support for HEIC, HEIF, RAW, and TIFF formats on iOS. |
@@ -4,8 +4,8 @@ | |||
|
|||
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> | |||
|
|||
#import <UniformTypeIdentifiers/UTCoreTypes.h> |
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.
This needs a blank line after it; they are different import sections.
#import "FLTPHPickerSaveImageToPathOperation.h" | ||
|
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.
Please undo this change.
UTTypeHEIC.identifier, | ||
UTTypeJPEG.identifier, | ||
UTTypeWebP.identifier, | ||
UTTypeGIF.identifier, |
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.
Why are we changing the codepath for types that already worked? Is this a preferred API?
[self processImage:image]; | ||
}]; | ||
return; | ||
NSArray *supportedRepresentations = @[ |
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.
"Supported" seems misleading here; this isn't an exhaustive list since there's the other codepath as well. What is distinct about these vs other types that makes them need to use a different code path (so that we can name the list accordingly)?
Are you still planning on updating this PR to address the review comments above? |
Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks! |
This PR attends to fix the image_picker no response error when picking the BMP images greater than iOS 14 in iOS simulator or iOS devices.
The reason why did not respond to the BMP image is that when picking the BMP format image the process step in FLTPHPickerSaveImageToPathOperation.mm will return nil in completionHandler and respond nothing back to dart.
The BMP image in videos is used from https://people.math.sc.edu/Burkardt/data/bmp/bmp_24.bmp in flutter/issues/95885
default.mov
This only happens in iOS 14 or greater version.
Also, reference in the flutter repo flutter/flutter#95885
Device info:iPhone13 iOS 15.0
After fix
default.mov
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.