[image_picker] Fix to keep Exif and so on in case of iOS.#866
[image_picker] Fix to keep Exif and so on in case of iOS.#866ko2ic wants to merge 1 commit intoflutter:masterfrom
Conversation
00a04d2 to
878b496
Compare
f110f81 to
d5f7aa4
Compare
|
/cc @xster |
|
@goderbauer I think you were looking at this issue. does it still need merging? |
|
@collinjackson I looked at (and fixed) EXIF data for the camera plugin. The image_picker uses a different API and I wouldn't be surprised if it has the same issue. So, this PR is probably still relevant. |
|
I'm running image_picker 0.4.10 on a Pixel 3 phone and the image is rotating as everyone has mentioned. |
|
@collinjackson, @goderbauer: I need this feature, so I fetched this PR then gave it a try, and everything worked fine for me. If this PR has no problems, could you merge it asap? |
6a496d5 to
3d3178a
Compare
* Keep gps and creationDate. * Fix to appropriate extension.
3d3178a to
2282ef8
Compare
|
I checked the operation after a long time, so I fixed it because there was a bug.
Are there any plans for this Pull Request to be merged? |
|
@collinjackson This PullRequest contains fixes to PNG transparency of at least IOS. If my judgment is correct, Could ios overwrite it with my source? In addition, this pull request is useful as at least creationDate and GPS information is hold. Could you make a review because I want to use exif by any means? |
|
Up |
cyanglaz
left a comment
There was a problem hiding this comment.
Thank you for your contribution! :)
I ran a quick look of the PR and left some comments. I will take another deep look into the actual meta data handling logic after we made a decision on how we are going to copy the meta data after you reading my suggestion on one of my comments.
|
|
||
| uint8_t c; | ||
| [imageData getBytes:&c length:1]; | ||
| switch (c) { |
There was a problem hiding this comment.
Can we make this an enum?
e.g, create a method like:
- (FlutterImagePickerFileType)getFileTypeFromFirstByte:(unit8_t c) {
switch(c) {
case 0x47:
return FlutterImagePickerFileTypeGIF;
.....
.....
}
}
| return scaledImage; | ||
| } | ||
|
|
||
| - (void)createImageFileAtPath:(NSString *)path contents:(NSData *)data { |
There was a problem hiding this comment.
Nit:
| - (void)createImageFileAtPath:(NSString *)path contents:(NSData *)data { | |
| - (void)createImageFileAtPath:(NSString *)path data:(NSData *)data { |
There was a problem hiding this comment.
This mimics the signature of NSFileManager class.
So I feel good with contents.
However, I leave it to you.
- (BOOL)createFileAtPath:(NSString *)path contents:(nullable NSData *)data attributes:(nullable NSDictionary<NSFileAttributeKey, id> *)attr;
| _arguments = nil; | ||
| } | ||
|
|
||
| - (void)createImageFileAtPath:(NSString *)path contents:(NSData *)data with:(PHAsset *)asset { |
There was a problem hiding this comment.
nit:
| - (void)createImageFileAtPath:(NSString *)path contents:(NSData *)data with:(PHAsset *)asset { | |
| - (void)createImageFileAtPath:(NSString *)path data:(NSData *)data asset:(PHAsset *)asset { |
| } | ||
| } else { | ||
| NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL]; | ||
| PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithALAssetURLs:@[ assetURL ] |
There was a problem hiding this comment.
assetURL can be nil if user take a fresh picture in the image_picker, which leads to crash here.
| } | ||
|
|
||
| - (void)createImageFileAtPath:(NSString *)path contents:(NSData *)data with:(PHAsset *)asset { | ||
| NSMutableDictionary *exifDict = [self fetchExifFrom:asset]; |
There was a problem hiding this comment.
Manually parsing the meta data seems to be risky. Is it possible to get the meta data from the original image directly and pass down to the new image?
Maybe when fetching image in requestImageDataForAsset, we can call (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(cgImage,0,NULL)); to get the whole meta data of the old image, and then somehow get a diff between the new image and the old image, then add the necessary stuff to the new image?
This way we don't manually parse the information like formatting time, adding hard coded GPS keys etc.
| _arguments = nil; | ||
| } | ||
|
|
||
| - (NSMutableDictionary *)fetchExifFrom:(PHAsset *)asset { |
There was a problem hiding this comment.
If a manual parser is inevitable, let's put the meta data handling into a separate file/class.
|
@ko2ic Are you able to keep working on this PR? I think this is valuable. If you are not able to continue, do you mind me taking this over? |
|
@cyanglaz I will hand over to you. |
|
Thanks to @ko2ic for the inspiration provided in this PR. |
Description
The image that can be acquired with image_picker is missing some information, even in the case of the original size.
CreateDateof Exif.GPSLatitude,GPSLatitude,GPSLongitudeRef,GPSLongitudeof GPS Tags.This pull request is a modification of these.
Limitation
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.///).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?