toWebp static method
Converts an image to WebP format.
Implementation
static Future<File?> toWebp(
File input,
String outputPath, {
int quality = 80,
}) async {
if (_cwebpPath == null) return null;
try {
final result = await Process.run(
_cwebpPath!,
['-q', quality.toString(), input.path, '-o', outputPath],
);
if (result.exitCode == 0 && await File(outputPath).exists()) {
return File(outputPath);
}
} catch (_) {}
return null;
}