聊城哪有做网站的,正定县住房和城乡建设局网站,河北省建设厅网站登陆设置,商业计划书ppt免费模板下载1.需求
在xxx产品需求中#xff0c;需要将png图片转为jpg图片。
2.引用库 image: ^4.1.3 Dart图像库提供了以各种图像文件格式加载、保存和操作图像的功能。 该库可以与dart:io和dart:html一起用于命令行、Flutter和web应用程序。 注#xff1a;4.0是该库先前版本的主要修订…1.需求
在xxx产品需求中需要将png图片转为jpg图片。
2.引用库 image: ^4.1.3 Dart图像库提供了以各种图像文件格式加载、保存和操作图像的功能。 该库可以与dart:io和dart:html一起用于命令行、Flutter和web应用程序。 注4.0是该库先前版本的主要修订版。 支持的图像格式 Read/Write JPGPNG / Animated APNGGIF / Animated GIFBMPTIFFTGAPVRICO Read Only WebP / Animated WebPPSDEXR Write Only CUR https://pub-web.flutter-io.cn/packages/image
3.代码实现
import package:image/image.dart as imglib;//原图片本地路径
final cmd imglib.Command()..decodeImageFile(‘/xxx/xxx/xx.png’);//image对象
var image await cmd.getImage();//转为jpg
var newImg imglib.encodeJpg(image);
if (newPath ! null) {File(‘/xxx/xxx/xx/new.jpg’).writeAsBytesSync(newImg);
}