Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.SessionConfiguration;
import android.media.CamcorderProfile;
import android.media.ExifInterface;
import android.media.Image;
import android.media.ImageReader;
import android.media.MediaRecorder;
Expand Down Expand Up @@ -423,6 +424,7 @@ public void takePicture(@NonNull final Result result) {
try (Image image = reader.acquireLatestImage()) {
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
writeToFile(buffer, file);
if(isFrontFacing) updateExifMetadata(file.getAbsolutePath());
pictureCaptureRequest.finish(file.getAbsolutePath());
} catch (IOException e) {
pictureCaptureRequest.error("IOError", "Failed saving image", null);
Expand All @@ -437,6 +439,13 @@ public void takePicture(@NonNull final Result result) {
}
}

void updateExifMetadata(String filePath) throws IOException {
ExifInterface exif = new ExifInterface(filePath);
exif.setAttribute(
ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_TRANSVERSE));
exif.saveAttributes();
}

private final CameraCaptureSession.CaptureCallback pictureCaptureCallback =
new CameraCaptureSession.CaptureCallback() {
@Override
Expand Down
3 changes: 3 additions & 0 deletions packages/camera/camera/ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ - (void)captureToFile:(FlutterResult)result API_AVAILABLE(ios(10)) {
[self getVideoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]];
}
}
if([_captureDevice position] == AVCaptureDevicePositionFront && connection.supportsVideoMirroring) {
connection.videoMirrored = YES;
}

[_capturePhotoOutput capturePhotoWithSettings:settings
delegate:[[FLTSavePhotoDelegate alloc] initWithPath:path
Expand Down