fluttercandies / flutter_image_compress

flutter image compress
MIT License
632 stars 215 forks source link

[Bug report] Compress do not respect aspect ratio #299

Open delfme opened 4 months ago

delfme commented 4 months ago

Version

^2.2.0

Platforms

Android

Device Model

Xiaomi Mi lite 5g

flutter info

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.21.0-17.0.pre.3, on macOS 14.2.1 23C71 darwin-arm64, locale en-IT)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)

How to reproduce?

1) Pickup a square image, in my case it is the one returned by PhotoManager

entity!
            .thumbnailDataWithOption(
          ThumbnailOption(
            size: const ThumbnailSize.square(350),
            quality: 65,
            format: ThumbnailFormat.jpeg
          ),
        )

2) Compress image by passing squareSize (ie. 100)

 await FlutterImageCompress.compressWithFile(
        file.path,
        quality: quality,
        minWidth: (squareSize != null) ? squareSize : width,
        minHeight: (squareSize != null) ? squareSize : null,

Result should be a 100X100px which shouldn't alter the PhotoManager thumb but it is a non-squared result.

Logs

No response

Example code (optional)

No response

Contact

No response