convertToPng32 static method
Конвертация изображения в PNG32
Implementation
static Future<void> convertToPng32(
String inputPath,
String outputPath,
) async {
final file = File(inputPath);
final bytes = await file.readAsBytes();
final image = img.decodeImage(bytes);
if (image == null) {
throw Exception('Не удалось декодировать изображение: $inputPath');
}
// Принудительно конвертируем в RGBA
final rgbaImage = image.convert(format: img.Format.uint8, numChannels: 4);
final outputFile = File(outputPath);
await outputFile.writeAsBytes(img.encodePng(rgbaImage));
}