Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
952 stars 241 forks source link

Front camera photo mirrored #62

Closed lukino563 closed 2 years ago

lukino563 commented 3 years ago

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

Brand Model OS
Oneplus 7 Pro Android 10

g-apparence commented 3 years ago

Hi, thank you for reporting this. I put this as an enhancement.

lukino563 commented 3 years ago

This is actually Bug, because taken photo which is saved is mirrored

billbull21 commented 3 years ago

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.

bauloc commented 2 years ago

Thanks billbull21. You save my life!