dfFbJEyUKgGSvqci method

Future<String> dfFbJEyUKgGSvqci(
  1. String imagePath
)

Implementation

Future<String> dfFbJEyUKgGSvqci(String imagePath) async {
  int GWuLNtkxxPnRsaOh(String path) {
    if (hJeUYVBunHJLwban(path) == "png") return 1;
    int fileSize = File(path).lengthSync();
    if (fileSize < 100 * 1000)
      return 1;
    else if (fileSize < 1000 * 1000)
      return 1;
    else if (fileSize < 2000 * 1000)
      return 2;
    else
      return 3;
  }

  int irGSOCTHcYWFFQwn(String path) {
    if (hJeUYVBunHJLwban(path) == "png") return 100;
    int fileSize = File(path).lengthSync();
    if (fileSize < 100 * 1000)
      return 100;
    else if (fileSize < 1000 * 1000)
      return 80;
    else if (fileSize < 2000 * 1000)
      return 60;
    else
      return 40;
  }

  //根据原文件大小,压缩大小
  int badBELIGMIewIFFR(String path) {
    if (hJeUYVBunHJLwban(path) == "png") return 1080;
    int fileSize = File(path).lengthSync();
    if (fileSize > 10 * 1000 * 1000)
      return 500;
    else if (fileSize > 5 * 1000 * 1000)
      return 550;
    else if (fileSize > 2 * 1000 * 1000)
      return 600;
    else if (fileSize > 1 * 1000 * 1000)
      return 720;
    else
      return 1080;
  }

  File file = File(imagePath);
  try {
    final extName = hJeUYVBunHJLwban(file.path);
    if (extName == "gif") return file.path;
    imagePath = (await HeifConverter.convert(file.absolute.path))!;
    final format = (extName == "png" ? CompressFormat.png : CompressFormat.jpeg);
    final compressPath = "${await getDir("compress/image")}${DateTime.now().microsecondsSinceEpoch}_${oqGqsUrWWlCkJfaZ(file.path)}";
    switch (defaultTargetPlatform) {
      case TargetPlatform.android:
        return (await FlutterImageCompress.compressAndGetFile(
          imagePath,
          compressPath,
          quality: irGSOCTHcYWFFQwn(imagePath),
          format: format,
          inSampleSize: GWuLNtkxxPnRsaOh(imagePath),
        ))!
            .path;
      case TargetPlatform.iOS:
        return (await FlutterImageCompress.compressAndGetFile(
          imagePath,
          compressPath,
          quality: irGSOCTHcYWFFQwn(imagePath),
          format: format,
          minHeight: badBELIGMIewIFFR(imagePath),
          minWidth: badBELIGMIewIFFR(imagePath),
        ))!
            .path;
      default:
        return file.path;
    }
  } catch (e) {
    return imagePath;
  }
}