Closed lukino563 closed 2 years ago
Hi, thank you for reporting this. I put this as an enhancement.
This is actually Bug, because taken photo which is saved is mirrored
there is pretty simple to fixed this bug,,,
you should mirror back as result file.
first, you need to install flutter plugin called image_editor.
then, look at my takePhoto function.
_takePhoto() async {
final Directory extDir = await getTemporaryDirectory();
final testDir =
await Directory('${extDir.path}/toko_kece/media').create(recursive: true);
final String filePath = '${testDir.path}/toko_kece${DateTime.now().millisecondsSinceEpoch}.jpg';
await _pictureController.takePicture(filePath);
// lets just make our phone vibrate
HapticFeedback.mediumImpact();
setState(() {});
print("----------------------------------");
print("TAKE PHOTO CALLED");
final file = File(filePath);
print("==> hastakePhoto : ${file.exists()} | path : $filePath");
print("----------------------------------");
if (_sensor.value == Sensors.FRONT) {
// 1. read the image from disk into memory
Uint8List imageBytes = await file.readAsBytes();
// 2. flip the image on the X axis
final ImageEditorOption option = ImageEditorOption();
option.addOption(FlipOption(horizontal: true));
imageBytes = await ImageEditor.editImage(image: imageBytes, imageEditorOption: option);
// 3. write the image back to disk
await file.delete();
final res = await file.writeAsBytes(imageBytes);
Navigator.of(context).pop(res);
} else {
Navigator.of(context).pop(file);
}
}
and voila,
you can preview the image after you mirror back the result from camera.
Thanks billbull21. You save my life!
Steps to Reproduce
Picture controller take photo on front camera
Expected results
Save photo with no mirror effect
Actual results
Save photo with mirror effect
About your device