更新时间:2023-01-23 10:50:53
看看图像包.以下是示例部分中提供的代码段,它将JPEG
转换为PNG
:
Take a look at the image package. The following is a snippet available in the examples section, which converts JPEG
to PNG
:
import 'dart:io';
import 'package:image/image.dart';
void main() {
// Read a jpeg image from file.
Image image = decodeImage(new File('test.jpg').readAsBytesSync());
// Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
Image thumbnail = copyResize(image, 120);
// Save the thumbnail as a PNG.
new File('out/thumbnail-test.png')
..writeAsBytesSync(encodePng(thumbnail));
}