Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit c75bc31

Browse files
committed
Add implementation of didFinishProcessingPhoto callback
1 parent 05879a3 commit c75bc31

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.0+2
2+
3+
* Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up.
4+
15
## 0.6.0+1
26

37
Updated README to inform users that iOS 10.0+ is needed for use

packages/camera/camera/ios/Classes/CameraPlugin.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
7676
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithData:data].CGImage
7777
scale:1.0
7878
orientation:[self getImageRotation]];
79+
7980
// TODO(sigurdm): Consider writing file asynchronously.
8081
bool success = [UIImageJPEGRepresentation(image, 1.0) writeToFile:_path atomically:YES];
8182
if (!success) {
@@ -85,6 +86,25 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
8586
_result(_path);
8687
}
8788

89+
- (void)captureOutput:(AVCapturePhotoOutput *)output
90+
didFinishProcessingPhoto:(AVCapturePhoto *)photo
91+
error:(NSError *)error API_AVAILABLE(ios(11.0)) {
92+
selfReference = nil;
93+
if (error) {
94+
_result(getFlutterError(error));
95+
return;
96+
}
97+
98+
NSData *photoData = [photo fileDataRepresentation];
99+
100+
bool success = [photoData writeToFile:_path atomically:YES];
101+
if (!success) {
102+
_result([FlutterError errorWithCode:@"IOError" message:@"Unable to write file" details:nil]);
103+
return;
104+
}
105+
_result(_path);
106+
}
107+
88108
- (UIImageOrientation)getImageRotation {
89109
float const threshold = 45.0;
90110
BOOL (^isNearValue)(float value1, float value2) = ^BOOL(float value1, float value2) {

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5-
version: 0.6.0+1
5+
version: 0.6.0+2
66
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
77

88
dependencies:

0 commit comments

Comments
 (0)