fluttercandies / flutter_image_compress

flutter image compress
MIT License
633 stars 214 forks source link

iOS crashed on webp and keep EXIF #217

Open SuhwanCha opened 2 years ago

SuhwanCha commented 2 years ago

iOS crashed when set output format as webp and keepExif: true.

  Future<File> compressAndGetFile(String targetPath) async {
    final result = await FlutterImageCompress.compressWithFile(
      file.absolute.path,
      quality: 50,
      format: CompressFormat.webp,
      keepExif: true, // it works if false, crashed if true
    );

    if (result == null) {
      throw CompressFailedException();
    }

    return File.fromRawPath(result);
  }
image
flutter doctor -v ``` ❯ flutter doctor -v [✓] Flutter (Channel unknown, 3.0.5, on macOS 12.5 21G72 darwin-arm, locale en-KR) • Flutter version 3.0.5 at /Users/suhwancha/development/GitHub/flutter • Upstream repository unknown • Framework revision f1875d570e (3 weeks ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/suhwancha/Library/Android/sdk • Platform android-32, build-tools 32.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [✓] VS Code (version 1.69.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.46.0 [✓] Connected device (3 available) • iPhone 13 Pro (mobile) • 87F95001-8EFB-4419-BB3D-310B6A7FD88F • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 12.5 21G72 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134 [✓] HTTP Host Availability • All required HTTP hosts are available ```
AlexV525 commented 2 years ago

Please verify if your exception trace is the same as #213.

SuhwanCha commented 2 years ago

Please verify if your exception trace is the same as #213.

It's different issue, issue you mentioned (#213 ) is about error when try to compress invalid image.

But, this issue happened when try to compress valid image to webp, keep exif.

And, I found same source code and same image works on Android. Only iOS crashed.

SuhwanCha commented 1 year ago

Relative article: https://stackoverflow.com/questions/68802152/unsupported-file-format-org-webmproject-webp-while-saving-cgimage-in-webp-fo

https://github.com/fluttercandies/flutter_image_compress/blob/52cefc9061dabec7197cd93a21c4d3e88aab848c/ios/Classes/SYPictureMetadata/SYMetadata.m#L112-L143