-2

Below photo is how I want to crop. But I only see how to crop in rectangle shape. Pardon my writing format. This is my first time asking question on stack overflow. This is my code for cropping image

Future<File> cropSquareImage(File imageFile) async =>
      await ImageCropper.cropImage(
        sourcePath: imageFile.path,
        aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
        aspectRatioPresets: [CropAspectRatioPreset.square],
        compressQuality: 70,
        compressFormat: ImageCompressFormat.jpg,
        androidUiSettings: androidUiSettingsLocked(),
        iosUiSettings: iosUiSettingsLocked(),
      );

photo crd.

Crop Image in circle shape

Wai Yan Min Min
  • 153
  • 1
  • 7

2 Answers2

1

Make the cropping element a circle with "border-radius" property, and display it using the same border-radius property. The image is still a rectangle, a square in this case, but if it is cropped as a circle and displayed as a circle, the user only sees a circular image crop.

There is no (reasonable) way to actually STORE an image file with a radius instead of an YYY x ZZZ pixels resolution.

  • this works perfect.But I have another question. After cropping,the image quality is low even after I set `Compressed Quality` to 100. – Wai Yan Min Min Sep 13 '21 at 14:48
  • I don't know what "Compressed Quality" is, but if you're displaying an image, then cropping it into a smaller image, and displaying the new smaller image at the same size as the original larger image, the new one will be stretched to fit the size and appear blurry/grainy. – Benjamonster Sep 14 '21 at 02:51
1

If you're using image_cropper, you can just set the property cropStyle to CropStyle.circle ImageCropper.cropImage(cropStyle: CropStyle.circle);

jeremynac
  • 1,204
  • 3
  • 11