美文网首页
2023-06-06 - 获取图片压缩功能

2023-06-06 - 获取图片压缩功能

作者: TsingQue | 来源:发表于2023-06-05 19:56 被阅读0次

  @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(() {});
        }
      });
    });
  }

相关文章

  • 图片压缩

    Android应用开发中三种常见的图片压缩方法,分别是:质量压缩法、比例压缩法(根据路径获取图片并压缩)和比例压缩...

  • Android之图片压缩和Uri与String类型的路径转换,获

    图片压缩和路径转换,获取图片,文件大小的工具类: 知道图片路径 Uri 转换为 String 路径对图片进行压缩并...

  • iOS 图片压缩 压缩到指定大小 质量和尺寸压缩

    有时候一些功能需要上传规定大小的图片,所以我们要对图片进行压缩。 思路:图片质量压缩 + 图片尺寸压缩首先对图片进...

  • iOS开发中图片质量的压缩

    上传前获取图片的质量以及尺寸(先进行尺寸的压缩再进行质量的压缩) 1.获取图片的质量:先将UIImage对象转成N...

  • tinyPng插件安装及使用

    功能:压缩图片资源,一次最多压缩500张 压缩的核心功能是TinyPng提供 https://tinypng.co...

  • vue(2019/7/15)

    vue实现照片选择或者拍照功能 照片格式校验, 图片质量压缩, 图片尺寸压缩, 图片离线保存, 图片base64编...

  • 图片处理

    图片保存到系统相册 获取图片信息(通过Exif-ExifInterface) 文件复制 图片压缩 Glide图片加载

  • 前端使用canvas对图片进行压缩

    纯前端对图片压缩 纯前端因为可以调用FileReader和canvas接口,在图片压缩方面非常便捷.思路就是获取图...

  • iOS 中常见的设置、保存、上传图片

    1.选择图片获取方式 对图片尺寸进行压缩 保存图片至沙盒

  • 图片压缩上传

    参考1-HTML5实现图片压缩上传功能参考2-移动前端—图片压缩上传实践参考3-移动端H5图片压缩上传 大体步骤 ...

网友评论

      本文标题:2023-06-06 - 获取图片压缩功能

      本文链接:https://www.haomeiwen.com/subject/oidwedtx.html