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

Commit

Permalink
Add implementation of didFinishProcessingPhoto callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Dec 16, 2020
1 parent b85d8eb commit a279ba4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.1

* Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up.

## 0.6.0

As part of implementing federated architecture and making the interface compatible with the web this version contains the following **breaking changes**:
Expand Down
21 changes: 21 additions & 0 deletions packages/camera/camera/ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithData:data].CGImage
scale:1.0
orientation:[self getImageRotation]];

// TODO(sigurdm): Consider writing file asynchronously.
bool success = [UIImageJPEGRepresentation(image, 1.0) writeToFile:_path atomically:YES];
if (!success) {
Expand All @@ -85,6 +86,26 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
_result(_path);
}

- (void)captureOutput:(AVCapturePhotoOutput *)output
didFinishProcessingPhoto:(AVCapturePhoto *)photo
error:(NSError *)error API_AVAILABLE(ios(11.0)){
selfReference = nil;
if (error) {
_result(getFlutterError(error));
return;
}

NSData * photoData = [photo fileDataRepresentation];

bool success = [photoData writeToFile:_path atomically:YES];
if (!success) {
_result([FlutterError errorWithCode:@"IOError" message:@"Unable to write file" details: nil]);
return;
}
_result(_path);

}

- (UIImageOrientation)getImageRotation {
float const threshold = 45.0;
BOOL (^isNearValue)(float value1, float value2) = ^BOOL(float value1, float value2) {
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
version: 0.6.0
version: 0.6.1
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera

dependencies:
Expand Down

0 comments on commit a279ba4

Please sign in to comment.