@override
Future thumbnail(String args) async {
final path = args.isNotEmpty ? args : 'test.png';
VRUtils.pathTothumbnail(args).then((value) async {
////判断缩略图是否存在
File txt = File(value);
var dir_bool = await txt.exists(); //返回真假
if (dir_bool) {
return;
}
final cmd = img.Command()
// Decode the image file at the given path
..decodeImageFile(path)
// Resize the image to a width of 64 pixels and a height that maintains the aspect ratio of the original.
..copyResize(width: 64)
// Write the image to a PNG file (determined by the suffix of the file path).
..writeToFile(value);
// On platforms that support Isolates, execute the image commands asynchronously on an isolate thread.
// Otherwise, the commands will be executed synchronously.
await cmd.executeThread().then((value) {
if (mounted) {
setState(() {});
}
});
});
}
2023-06-06 - 获取图片压缩功能
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 前言 发起这个博客的原因是近期有个需求,当用户在APP中发送图片时,APP要显示将图片压缩到指定尺寸的选项,选项中...
- TakePhoto 简介 TakePhoto是一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、...
- 一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库https://...
- 先说一下 为什么进行图片压缩 主要有两个方面的原因 一是为了优化交互 减少上传图片的等待时间 和响应时间而是为了减...
- 原因:自己公司项目有IM功,基于万物皆克抄原则,还原微信你可发送的图片功能 要求获取的图片: 1:相机图片2:截图...