compressImage static method

Future<File> compressImage({
  1. required File image,
  2. int quality = 70,
  3. int percentage = 70,
  4. int targetWidth = 0,
  5. int targetHeight = 0,
})

Compress an image

Compresses the given image. percentage controls by how much the image should be resized. (0-100) quality controls how strong the compression should be. (0-100) Use targetWidth and targetHeight to resize the image for a specific target size.

Implementation

static Future<File> compressImage({
  required File image,
  int quality = 70,
  int percentage = 70,
  int targetWidth = 0,
  int targetHeight = 0,
}) async {
  final compressedFile = await FlutterNativeImage.compressImage(
    image.absolute.path,
    percentage: percentage,
    quality: quality,
    targetWidth: targetWidth,
    targetHeight: targetHeight,
  );

  return compressedFile;
}