Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After loading and cropping an image from gallery it doesn't save the cropped image in the path passed but if I shot an image it works just fine #134

Open
Bogghi opened this issue May 24, 2023 · 0 comments

Comments

@Bogghi
Copy link

Bogghi commented May 24, 2023

Hi,
I'm having an issue with saving the image cropped after loading it from the gallery. Basically it load the image just fine in the UI and it crop correctly but when it comes to saving the cropped image it fails but it doesn't throw any exception.
Im running an ipad mini gen 5 with ipadOS 16.3.1.

Here's my steps:

 Future<void> getImage(context) async{
    bool isCameraGranted = await Permission.camera.request().isGranted;
    late bool success;

    if(!isCameraGranted){
      isCameraGranted = await Permission.camera.request() == PermissionStatus.granted;
    }

    if(!isCameraGranted)
      return;

    final String imagePath = await getPath();
    final String compressedPath = await getPath();

    success = await EdgeDetection.detectEdge(imagePath,
      canUseGallery: true,
      androidScanTitle: 'Scanning', // use custom localizations for android
      androidCropTitle: 'Crop',
      androidCropBlackWhiteTitle: 'Black White',
      androidCropReset: 'Reset',
    );

    // success = await EdgeDetection.detectEdgeFromGallery(
    //   imagePath
    // );
    print(File(imagePath).lengthSync());

    if(!success)
      return;

    await FlutterImageCompress.compressAndGetFile(
      imagePath,
      compressedPath,
      quality: 5
    );

    setState(() {
      scannedFile.add(compressedPath);
    });
  }

at the print i get this error, if i remove the print i get an error from the compress signaling that the image doesn't exist.

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot retrieve length of file, path = '/var/mobile/Containers/Data/Application/681E693B-504B-46E2-8D29-C0333643FE0E/Library/Caches/79.jpeg' (OS Error: No such file or directory, errno = 2)
#0      _File.throwIfError (dart:io/file_impl.dart:635:7)
#1      _File.lengthSync (dart:io/file_impl.dart:377:5)
#2      _BrchdocDocumentCatcherState.getImage (package:app_rm_nca/page/brchdoc/brchdoc_document_capturer.dart:143:27)

when i shoot an image i get this values, witch is correct and it works just fine

flutter: 1558066

when trying to use the EdgeDetection.detectEdgeFromGallery i get the same errors.

Has anyone encountered a similar issue? I'm stack not knowing what to do or how to work around this issue.

Best regards guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant