applyImageProperties function
Implementation
Future<Uint8List?> applyImageProperties(
Uint8List list, ImageProperties props, ImageType type) async {
final cmd = img.Command()..decodeImage(list);
if (props.flipHorizontal) {
cmd.flip(direction: img.FlipDirection.horizontal);
}
if (props.flipVertical) {
cmd.flip(direction: img.FlipDirection.vertical);
}
if (props.rotation != 0) {
cmd.copyRotate(angle: props.rotation);
}
var cropRect = props.cropRect;
if (cropRect != Rect.zero) {
cmd.copyCrop(
x: cropRect.left.toInt(),
y: cropRect.top.toInt(),
width: cropRect.width.toInt(),
height: cropRect.height.toInt(),
);
}
switch (type) {
case ImageType.png:
cmd.encodePng();
break;
case ImageType.jpg:
cmd.encodeJpg();
break;
case ImageType.gif:
cmd.encodeGif();
break;
case ImageType.bmp:
cmd.encodeBmp();
break;
case ImageType.tiff:
cmd.encodeTiff();
break;
case ImageType.tga:
cmd.encodeTga();
break;
case ImageType.pvr:
cmd.encodePvr();
break;
case ImageType.ico:
cmd.encodeIco();
break;
}
var result = await cmd.executeThread();
return result.outputBytes;
}