压缩图像

对象存储 快速入门-SDK 文档-文档中心-腾讯云 https://cloud.tencent.com/document/product/436/86294

tencentcloud_cos_sdk_plugin 目前兼容支持 iOS、Android,是通过 Flutter Plugin 桥接原生 AndroidiOS 的 COS SDK 实现。

 

 

 

Flutter 压缩图像的最佳方式(3种任你选) - 知乎 https://zhuanlan.zhihu.com/p/454494266

flutter_image_compress | Flutter Package https://pub-web.flutter-io.cn/packages/flutter_image_compress

 


  // 1. compress file and get Uint8List
  Future<Uint8List> testCompressFile(File file) async {
    var result = await FlutterImageCompress.compressWithFile(
      file.absolute.path,
      minWidth: 2300,
      minHeight: 1500,
      quality: 94,
      rotate: 90,
    );
    print(file.lengthSync());
    print(result.length);
    return result;
  }

  // 2. compress file and get file.
  Future<File> testCompressAndGetFile(File file, String targetPath) async {
    var result = await FlutterImageCompress.compressAndGetFile(
        file.absolute.path, targetPath,
        quality: 88,
        rotate: 180,
      );

    print(file.lengthSync());
    print(result.lengthSync());

    return result;
  }

  // 3. compress asset and get Uint8List.
  Future<Uint8List> testCompressAsset(String assetName) async {
    var list = await FlutterImageCompress.compressAssetImage(
      assetName,
      minHeight: 1920,
      minWidth: 1080,
      quality: 96,
      rotate: 180,
    );

    return list;
  }

  // 4. compress Uint8List and get another Uint8List.
  Future<Uint8List> testComporessList(Uint8List list) async {
    var result = await FlutterImageCompress.compressWithList(
      list,
      minHeight: 1920,
      minWidth: 1080,
      quality: 96,
      rotate: 135,
    );
    print(list.length);
    print(result.length);
    return result;
  }

 

 

 

 

 

 

posted @ 2023-08-29 07:28  papering  阅读(39)  评论(0编辑  收藏  举报