convertImageToJpg function

Future<Uint8List?> convertImageToJpg({
  1. required File inputFile,
  2. int quality = 100,
  3. JpegChroma chroma = JpegChroma.yuv444,
})

to the JPEG format.

Implementation

Future<Uint8List?> convertImageToJpg({
  required File inputFile,
  int quality = 100,
  JpegChroma chroma = JpegChroma.yuv444,
}) async {
  final imageBytes = inputFile.readAsBytesSync();

  final image = decodeImage(imageBytes);

  if (image == null) {
    logDebug('covert image to jpg failed');
    return null;
  }

  final jpgBytes = encodeJpg(image);

  return jpgBytes;
}