lykhonis / image_crop

A flutter plugin to crop image on iOS and Android.
Apache License 2.0
328 stars 202 forks source link

Poor quality during crop #93

Open AlexandreKueny opened 2 years ago

AlexandreKueny commented 2 years ago

When I take a picture, the image have a good quality, but when I try to use it in Crop, it becomes completely blurry. Here are two screenshots of the image in the camera and during the Crop:

Capture d’écran 2022-08-12 à 15 37 32 Capture d’écran 2022-08-12 à 15 38 24

This is on emulator (Pixel 4 API 30) but I have the same issue on my physical device (OnePlus 9 Pro).

You can find my code here

471448446 commented 1 year ago

on the demo example/lib/main.dart:

  Future<void> _openImage() async {
    final pickedFile =
        await ImagePicker().pickImage(source: ImageSource.gallery);
    final file = File(pickedFile?.path);
    final sample = await ImageCrop.sampleImage(
      file: file,
      preferredSize: context.size?.longestSide.ceil(),
    );

    _sample?.delete();
    _file?.delete();

    setState(() {
      _sample = sample;
      _file = file;
    });
  }

replace to

  Future<void> _openImage() async {
    final pickedFile =
        await ImagePicker().pickImage(source: ImageSource.gallery);
    final file = File(pickedFile?.path);
    // final sample = await ImageCrop.sampleImage(
    //   file: file,
    //   preferredSize: context.size?.longestSide.ceil(),
    // );
    //
    // _sample?.delete();
    _file?.delete();

    setState(() {
      _sample = file; // direct use origin file
      _file = file;
    });
  }
LeGoffMael commented 1 year ago

I had the same issue on android, the cropped image were twice smaller than the preferredSize value.

this PR fixed it #75