xCreateThumbnails_fromImage method

Uint8List xCreateThumbnails_fromImage(
  1. Uint8List image_payload, {
  2. int? width,
})

Metodo per la creazione di una miniatura da una Foto

Implementation

Uint8List xCreateThumbnails_fromImage(Uint8List image_payload, {int? width}) {
  final imgOri = img.decodeJpg(image_payload)!;
  if (width == null) width = 100;
  var height = width * imgOri.height ~/ imgOri.width;
  if (height > 100) {
    height = 100;
    width = height * imgOri.width ~/ imgOri.height;
  }
  var resizedImg = img.copyResize(imgOri, width: width, height: height);
  final pngBytes = img.encodePng(resizedImg);
  return pngBytes;
}