diff --git a/.github/workflows/publish_on_release.yml b/.github/workflows/publish_on_release.yml index 620f8fc..85a620b 100644 --- a/.github/workflows/publish_on_release.yml +++ b/.github/workflows/publish_on_release.yml @@ -11,9 +11,26 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v3 - - name: Publish - uses: k-paxian/dart-package-publisher@master + - name: Install flutter + uses: subosito/flutter-action@v2 with: - credentialJson: ${{ secrets.CREDENTIAL_JSON }} - flutter: true - skipTests: true + flutter-version: '3.7.7' + channel: 'stable' + - run: flutter --version + - name: Install dependencies + run: flutter pub get + - name: Install melos + run: flutter pub global activate melos + - name: Get packages + run: | + melos bootstrap + melos run get + - name: Try to publish + run: melos publish --yes --dry-run + - name: Write token to local + run: | + mkdir -p ~/.config/dart + echo ${{ secrets.CREDENTIAL_JSON }} > ~/.config/dart/pub-credentials.json + - name: Publish to pub.dev + run: melos publish --yes --no-dry-run + \ No newline at end of file diff --git a/.github/workflows/runnable.yml b/.github/workflows/runnable.yml index aabd318..98bd243 100644 --- a/.github/workflows/runnable.yml +++ b/.github/workflows/runnable.yml @@ -30,8 +30,14 @@ jobs: flutter --version - name: Prepare dependencies run: flutter pub get - - name: Analyse the repo - run: flutter analyze lib example/lib + - name: Get melos + run: dart pub global activate melos + - name: Init melos + run: | + melos bootstrap + melos run get + - name: Analyze + run: melos run analyze test_iOS: needs: analyze name: Test iOS on ${{ matrix.os }} @@ -52,7 +58,14 @@ jobs: - run: dart --version - run: flutter --version - run: flutter pub get - - run: cd example; flutter build ios --no-codesign + - name: Get melos + run: dart pub global activate melos + - name: Init melos + run: | + melos bootstrap + melos run get + - name: Build iOS debug with melos + run: melos run try_build_ios test_android: needs: analyze @@ -74,4 +87,10 @@ jobs: - run: flutter --version - run: flutter pub get - run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;21.4.7075529" - - run: cd example; flutter build apk --debug + - name: Get melos + run: dart pub global activate melos + - name: Init melos + run: | + melos bootstrap + melos run get + - run: melos run try_build_apk diff --git a/.gitignore b/.gitignore index 40366a1..6d91a31 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -*.lock .env example/macos/Flutter/ephemeral/flutter_export_environment.sh + +pubspec_overrides.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3612c2c..1954c0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,19 @@ # CONTRIBUTING Please submit changes to the main branch, and make sure your code is willing to comply with MIT style. + +## About development + +The repo is manage by [melos][], so you need to install it first. + +```bash +dart pub global activate melos +``` + +Then you can run `melos bootstrap` to install all dependencies. + +```bash +melos bootstrap +``` + +[melos]: https://melos.invertase.dev diff --git a/LICENSE b/LICENSE index 2dc7fbc..09f513b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 caijinglong +Copyright (c) 2023 FlutterCandies Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/melos.yaml b/melos.yaml new file mode 100644 index 0000000..8bd70c4 --- /dev/null +++ b/melos.yaml @@ -0,0 +1,39 @@ +name: flutter_image_compress +repository: https://github.com/fluttercandies/flutter_image_compress + +packages: + - packages/** + +scripts: + analyze: + exec: dart analyze . + get: + exec: flutter pub get + test: + exec: flutter test + format: + exec: dart format --set-exit-if-changed . + try_build_apk: + exec: flutter build apk --debug + packageFilters: + fileExists: lib/main.dart + try_build_ios: + exec: | + flutter pub get + flutter build ios --debug --no-codesign + packageFilters: + fileExists: lib/main.dart + cp_files: + exec: | + if [ -f "../../LICENSE" ]; then + cp ../../LICENSE LICENSE + fi + if [ -f "../../README.md" ]; then + cp ../../README.md README.md + fi + +sdkPath: auto + +command: + version: + releaseUrl: true diff --git a/migrate.md b/migrate.md new file mode 100644 index 0000000..1d79c75 --- /dev/null +++ b/migrate.md @@ -0,0 +1,44 @@ +# Migrate document + +## 1.x to 2.x + +There are several changes + +- The return value of `File` is now changed to the `XFile` type of [cross_file][], so you need to change the code to `XFile`. + +1.0: + +```dart +final File file = FlutterImageCompress.compressAndGetFile( + file.absolute.path, + targetPath, + quality: 90, + minWidth: 1024, + minHeight: 1024, + rotate: 90, + ); + +int length = file.lengthSync(); +Uint8List buffer = file.readAsBytesSync(); +``` + +2.0: + +```dart +final XFile file = await FlutterImageCompress.compressAndGetFile( + file.absolute.path, + targetPath, + quality: 90, + minWidth: 1024, + minHeight: 1024, + rotate: 90, + ); + +int length = await file.length(); +Uint8List buffer = await file.readAsBytes(); +``` + +Other usage of `XFile` to see [document][xfile] + +[cross_file]: https://pub.dev/packages/cross_file +[xfile]: https://pub.dev/documentation/cross_file/latest/cross_file/XFile-class.html diff --git a/packages/flutter_image_compress/.gitignore b/packages/flutter_image_compress/.gitignore new file mode 100644 index 0000000..40366a1 --- /dev/null +++ b/packages/flutter_image_compress/.gitignore @@ -0,0 +1,40 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +*.lock +.env +example/macos/Flutter/ephemeral/flutter_export_environment.sh diff --git a/CHANGELOG.md b/packages/flutter_image_compress/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to packages/flutter_image_compress/CHANGELOG.md diff --git a/packages/flutter_image_compress/LICENSE b/packages/flutter_image_compress/LICENSE new file mode 100644 index 0000000..09f513b --- /dev/null +++ b/packages/flutter_image_compress/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 FlutterCandies + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/flutter_image_compress/README.md b/packages/flutter_image_compress/README.md new file mode 100644 index 0000000..9a17023 --- /dev/null +++ b/packages/flutter_image_compress/README.md @@ -0,0 +1,322 @@ +# flutter_image_compress + +[![ImageCompress](https://img.shields.io/badge/fluttercandies-ImageCompress-blue.svg)](https://github.com/fluttercandies/flutter_image_compress) +[![pub package](https://img.shields.io/pub/v/flutter_image_compress.svg)](https://pub.dartlang.org/packages/flutter_image_compress) +[![GitHub license](https://img.shields.io/github/license/fluttercandies/flutter_image_compress?style=flat-square)](https://github.com/fluttercandies/flutter_image_compress/blob/main/LICENSE) +[![GitHub stars](https://img.shields.io/github/stars/fluttercandies/flutter_image_compress.svg?style=social&label=Stars)](https://github.com/fluttercandies/flutter_image_compress) +[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes) +FlutterCandies + +Compresses image as native plugin (Obj-C/Kotlin). This library works on Android and iOS. + +- [flutter_image_compress](#flutter_image_compress) + - [Why don't you use dart to do it](#why-dont-you-use-dart-to-do-it) + - [Usage](#usage) + - [About common params](#about-common-params) + - [minWidth and minHeight](#minwidth-and-minheight) + - [rotate](#rotate) + - [autoCorrectionAngle](#autocorrectionangle) + - [quality](#quality) + - [format](#format) + - [Webp](#webp) + - [HEIF(Heic)](#heifheic) + - [Heif for iOS](#heif-for-ios) + - [Heif for Android](#heif-for-android) + - [inSampleSize](#insamplesize) + - [keepExif](#keepexif) + - [Result](#result) + - [About `List` and `Uint8List`](#about-listint-and-uint8list) + - [Runtime Error](#runtime-error) + - [Android](#android) + - [Troubleshooting](#troubleshooting) + - [Compressing returns `null`](#compressing-returns-null) + - [About EXIF information](#about-exif-information) + +## Why don't you use dart to do it + +Q:Dart already has image compression libraries. Why use native? + +A:For unknown reasons, image compression in Dart language is not efficient, +even in release version. Using isolate does not solve the problem. + +## Usage + +```yaml +dependencies: + flutter_image_compress: ^1.0.0-nullsafety +``` + +```dart +import 'package:flutter_image_compress/flutter_image_compress.dart'; +``` + +Use as: + +[See full example](https://github.com/fluttercandies/flutter_image_compress/blob/main/example/lib/main.dart) + +There are several ways to use the library api. + +```dart + + // 1. compress file and get Uint8List + Future 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 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 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 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; + } +``` + +## About common params + +### minWidth and minHeight + +`minWidth` and `minHeight` are constraints on image scaling. + +For example, a 4000\*2000 image, `minWidth` set to 1920, +`minHeight` set to 1080, the calculation is as follows: + +```dart +// Using dart as an example, the actual implementation is Kotlin or OC. +import 'dart:math' as math; + +void main() { + var scale = calcScale( + srcWidth: 4000, + srcHeight: 2000, + minWidth: 1920, + minHeight: 1080, + ); + + print("scale = $scale"); // scale = 1.8518518518518519 + print("target width = ${4000 / scale}, height = ${2000 / scale}"); // target width = 2160.0, height = 1080.0 +} + +double calcScale({ + double srcWidth, + double srcHeight, + double minWidth, + double minHeight, +}) { + var scaleW = srcWidth / minWidth; + var scaleH = srcHeight / minHeight; + var scale = math.max(1.0, math.min(scaleW, scaleH)); + return scale; +} +``` + +If your image width is smaller than `minWidth` or height smaller than `minHeight`, +scale will be 1, that is, the size will not change. + +### rotate + +If you need to rotate the picture, use this parameter. + +### autoCorrectionAngle + +This property only exists in the version after 0.5.0. + +And for historical reasons, there may be conflicts with rotate attributes, +which need to be self-corrected. + +Modify rotate to 0 or autoCorrectionAngle to false. + +### quality + +Quality of target image. + +If `format` is png, the param will be ignored in iOS. + +### format + +Supports jpeg or png, default is jpeg. + +The format class sign `enum CompressFormat`. + +Heif and webp Partially supported. + +#### Webp + +Support android by the system api (speed very nice). +The library also supports iOS. However, we're using +[third-party libraries](https://github.com/SDWebImage/SDWebImageWebPCoder), +it is not recommended due to encoding speed. +In the future, `libwebp` by google (C/C++) may be used to do coding work, +bypassing other three-party libraries, but there are no plan for that currently. + +#### HEIF(Heic) + +##### Heif for iOS + +Only support iOS 11+. + +##### Heif for Android + +Use [HeifWriter][] for the implementation. + +Only support API 28+. + +And may require hardware encoder support, +does not guarantee that all devices _above_ API 28 are available. + +[heifwriter]: https://developer.android.com/reference/androidx/heifwriter/HeifWriter.html + +### inSampleSize + +The param is only support android. + +For a description of this parameter, see the [Android official website](https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize). + +### keepExif + +If this parameter is true, EXIF information is saved in the compressed result. + +Attention should be paid to the following points: + +1. Default value is false. +2. Even if set to true, the direction attribute is not included. +3. Only support jpg format, PNG format does not support. + +## Result + +The result of returning a List collection will not have null, but will always be an empty array. + +The returned file may be null. In addition, please decide for yourself whether the file exists. + +### About `List` and `Uint8List` + +You may need to convert `List` to `Uint8List` to display images. + +To use `Uint8List`, you need import package to your code like this: + +![img](https://raw.githubusercontent.com/CaiJingLong/asset_for_picgo/master/20190519111735.png) + +```dart +final image = Uint8List.fromList(imageList); +ImageProvider provider = MemoryImage(Uint8List.fromList(imageList)); +``` + +Usage in `Image` Widget: + +```dart +Future _compressImage() async { + List image = await testCompressFile(file); + ImageProvider provider = MemoryImage(Uint8List.fromList(image)); + imageWidget = Image( + image: provider ?? AssetImage('img/img.jpg'), + ); +} +``` + +Write to file usage: + +```dart +Future writeToFile(List image, String filePath) { + return File(filePath).writeAsBytes(image, flush: true); +} +``` + +## Runtime Error + +Because of some support issues, +all APIs will be compatible with format and system compatibility, +and an exception (`UnsupportedError`) may be thrown, +so if you insist on using webp and heic formats, +please catch the exception yourself and use it on unsupported devices jpeg compression. + +Example: + +```dart +Future compressAndTryCatch(String path) async { + Uint8List result; + try { + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.heic, + ); + } on UnsupportedError catch (e) { + print(e); + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.jpeg, + ); + } + return result; +} +``` + +## Android + +You may need to update Kotlin to version `1.5.21` or higher. + +## Troubleshooting + +### Compressing returns `null` + +Sometimes, compressing will return null. You should check if you can read/write the file, +and the parent folder of the target file must exist. + +For example, use the [path_provider](https://pub.dartlang.org/packages/path_provide) +plugin to access some application folders, +and use a permission plugin to request permission to access SD cards on Android/iOS. + +## About EXIF information + +Using this library, EXIF information will be removed by default. + +EXIF information can be retained by setting keepExif to true, +but not `direction` information. + +- PNG/JPEG encoder: System API. +- WebP encoder: + - [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) on iOS. + - System API on Android. +- HEIF encoder: System API. + - [HeifWriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) on Android P+. diff --git a/example/.gitignore b/packages/flutter_image_compress/example/.gitignore similarity index 100% rename from example/.gitignore rename to packages/flutter_image_compress/example/.gitignore diff --git a/example/.metadata b/packages/flutter_image_compress/example/.metadata similarity index 100% rename from example/.metadata rename to packages/flutter_image_compress/example/.metadata diff --git a/example/README.md b/packages/flutter_image_compress/example/README.md similarity index 100% rename from example/README.md rename to packages/flutter_image_compress/example/README.md diff --git a/android/.gitignore b/packages/flutter_image_compress/example/android/.gitignore similarity index 100% rename from android/.gitignore rename to packages/flutter_image_compress/example/android/.gitignore diff --git a/example/android/app/build.gradle b/packages/flutter_image_compress/example/android/app/build.gradle similarity index 100% rename from example/android/app/build.gradle rename to packages/flutter_image_compress/example/android/app/build.gradle diff --git a/example/android/app/src/main/AndroidManifest.xml b/packages/flutter_image_compress/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from example/android/app/src/main/AndroidManifest.xml rename to packages/flutter_image_compress/example/android/app/src/main/AndroidManifest.xml diff --git a/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/BuildConfig.java b/packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/BuildConfig.java similarity index 100% rename from example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/BuildConfig.java rename to packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/BuildConfig.java diff --git a/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/Manifest.java b/packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/Manifest.java similarity index 100% rename from example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/Manifest.java rename to packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/Manifest.java diff --git a/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/R.java b/packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/R.java similarity index 100% rename from example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/R.java rename to packages/flutter_image_compress/example/android/app/src/main/gen/com/fluttercandies/flutterimagecompressexample/R.java diff --git a/example/android/app/src/main/kotlin/com/fluttercandies/flutterimagecompressexample/MainActivity.kt b/packages/flutter_image_compress/example/android/app/src/main/kotlin/com/fluttercandies/flutterimagecompressexample/MainActivity.kt similarity index 100% rename from example/android/app/src/main/kotlin/com/fluttercandies/flutterimagecompressexample/MainActivity.kt rename to packages/flutter_image_compress/example/android/app/src/main/kotlin/com/fluttercandies/flutterimagecompressexample/MainActivity.kt diff --git a/example/android/app/src/main/res/drawable/laucher_background.xml b/packages/flutter_image_compress/example/android/app/src/main/res/drawable/laucher_background.xml similarity index 100% rename from example/android/app/src/main/res/drawable/laucher_background.xml rename to packages/flutter_image_compress/example/android/app/src/main/res/drawable/laucher_background.xml diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/packages/flutter_image_compress/example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from example/android/app/src/main/res/drawable/launch_background.xml rename to packages/flutter_image_compress/example/android/app/src/main/res/drawable/launch_background.xml diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/flutter_image_compress/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to packages/flutter_image_compress/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/flutter_image_compress/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to packages/flutter_image_compress/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to packages/flutter_image_compress/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/example/android/app/src/main/res/values/styles.xml b/packages/flutter_image_compress/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from example/android/app/src/main/res/values/styles.xml rename to packages/flutter_image_compress/example/android/app/src/main/res/values/styles.xml diff --git a/example/android/build.gradle b/packages/flutter_image_compress/example/android/build.gradle similarity index 100% rename from example/android/build.gradle rename to packages/flutter_image_compress/example/android/build.gradle diff --git a/example/android/gradle.properties b/packages/flutter_image_compress/example/android/gradle.properties similarity index 100% rename from example/android/gradle.properties rename to packages/flutter_image_compress/example/android/gradle.properties diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/flutter_image_compress/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from example/android/gradle/wrapper/gradle-wrapper.properties rename to packages/flutter_image_compress/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/example/android/settings.gradle b/packages/flutter_image_compress/example/android/settings.gradle similarity index 100% rename from example/android/settings.gradle rename to packages/flutter_image_compress/example/android/settings.gradle diff --git a/example/go/.gitignore b/packages/flutter_image_compress/example/go/.gitignore similarity index 100% rename from example/go/.gitignore rename to packages/flutter_image_compress/example/go/.gitignore diff --git a/example/go/assets/icon.png b/packages/flutter_image_compress/example/go/assets/icon.png similarity index 100% rename from example/go/assets/icon.png rename to packages/flutter_image_compress/example/go/assets/icon.png diff --git a/example/go/cmd/import-flutter_image_compress-plugin.go b/packages/flutter_image_compress/example/go/cmd/import-flutter_image_compress-plugin.go similarity index 100% rename from example/go/cmd/import-flutter_image_compress-plugin.go rename to packages/flutter_image_compress/example/go/cmd/import-flutter_image_compress-plugin.go diff --git a/example/go/cmd/import-path_provider-plugin.go b/packages/flutter_image_compress/example/go/cmd/import-path_provider-plugin.go similarity index 100% rename from example/go/cmd/import-path_provider-plugin.go rename to packages/flutter_image_compress/example/go/cmd/import-path_provider-plugin.go diff --git a/example/go/cmd/main.go b/packages/flutter_image_compress/example/go/cmd/main.go similarity index 100% rename from example/go/cmd/main.go rename to packages/flutter_image_compress/example/go/cmd/main.go diff --git a/example/go/cmd/options.go b/packages/flutter_image_compress/example/go/cmd/options.go similarity index 100% rename from example/go/cmd/options.go rename to packages/flutter_image_compress/example/go/cmd/options.go diff --git a/example/go/go.mod b/packages/flutter_image_compress/example/go/go.mod similarity index 100% rename from example/go/go.mod rename to packages/flutter_image_compress/example/go/go.mod diff --git a/example/go/go.sum b/packages/flutter_image_compress/example/go/go.sum similarity index 100% rename from example/go/go.sum rename to packages/flutter_image_compress/example/go/go.sum diff --git a/example/go/hover.yaml b/packages/flutter_image_compress/example/go/hover.yaml similarity index 100% rename from example/go/hover.yaml rename to packages/flutter_image_compress/example/go/hover.yaml diff --git a/example/img/auto-angle.jpg b/packages/flutter_image_compress/example/img/auto-angle.jpg similarity index 100% rename from example/img/auto-angle.jpg rename to packages/flutter_image_compress/example/img/auto-angle.jpg diff --git a/example/img/have-exif.jpg b/packages/flutter_image_compress/example/img/have-exif.jpg similarity index 100% rename from example/img/have-exif.jpg rename to packages/flutter_image_compress/example/img/have-exif.jpg diff --git a/example/img/header.png b/packages/flutter_image_compress/example/img/header.png similarity index 100% rename from example/img/header.png rename to packages/flutter_image_compress/example/img/header.png diff --git a/example/img/icon.webp b/packages/flutter_image_compress/example/img/icon.webp similarity index 100% rename from example/img/icon.webp rename to packages/flutter_image_compress/example/img/icon.webp diff --git a/example/img/img.jpg b/packages/flutter_image_compress/example/img/img.jpg similarity index 100% rename from example/img/img.jpg rename to packages/flutter_image_compress/example/img/img.jpg diff --git a/example/img/transparent-background.png b/packages/flutter_image_compress/example/img/transparent-background.png similarity index 100% rename from example/img/transparent-background.png rename to packages/flutter_image_compress/example/img/transparent-background.png diff --git a/example/ios/.gitignore b/packages/flutter_image_compress/example/ios/.gitignore similarity index 100% rename from example/ios/.gitignore rename to packages/flutter_image_compress/example/ios/.gitignore diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/packages/flutter_image_compress/example/ios/Flutter/AppFrameworkInfo.plist similarity index 96% rename from example/ios/Flutter/AppFrameworkInfo.plist rename to packages/flutter_image_compress/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/flutter_image_compress/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Flutter/Debug.xcconfig b/packages/flutter_image_compress/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from example/ios/Flutter/Debug.xcconfig rename to packages/flutter_image_compress/example/ios/Flutter/Debug.xcconfig diff --git a/example/ios/Flutter/Release.xcconfig b/packages/flutter_image_compress/example/ios/Flutter/Release.xcconfig similarity index 100% rename from example/ios/Flutter/Release.xcconfig rename to packages/flutter_image_compress/example/ios/Flutter/Release.xcconfig diff --git a/example/ios/Podfile b/packages/flutter_image_compress/example/ios/Podfile similarity index 99% rename from example/ios/Podfile rename to packages/flutter_image_compress/example/ios/Podfile index 3b05adc..47f6ad6 100644 --- a/example/ios/Podfile +++ b/packages/flutter_image_compress/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '9.0' +platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/packages/flutter_image_compress/example/ios/Runner.xcodeproj/project.pbxproj similarity index 97% rename from example/ios/Runner.xcodeproj/project.pbxproj rename to packages/flutter_image_compress/example/ios/Runner.xcodeproj/project.pbxproj index 048e220..7c9e6cf 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/flutter_image_compress/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -211,6 +211,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -225,6 +226,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -265,18 +267,18 @@ "${BUILT_PRODUCTS_DIR}/Mantle/Mantle.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder/SDWebImageWebPCoder.framework", - "${BUILT_PRODUCTS_DIR}/flutter_image_compress/flutter_image_compress.framework", + "${BUILT_PRODUCTS_DIR}/flutter_image_compress_common/flutter_image_compress_common.framework", "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework", - "${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework", + "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mantle.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_image_compress.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_image_compress_common.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -363,7 +365,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -410,7 +412,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -431,7 +433,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -455,7 +460,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/flutter_image_compress/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to packages/flutter_image_compress/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/flutter_image_compress/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to packages/flutter_image_compress/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/flutter_image_compress/example/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from example/ios/Runner.xcworkspace/contents.xcworkspacedata rename to packages/flutter_image_compress/example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/flutter_image_compress/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to packages/flutter_image_compress/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/example/ios/Runner/AppDelegate.h b/packages/flutter_image_compress/example/ios/Runner/AppDelegate.h similarity index 100% rename from example/ios/Runner/AppDelegate.h rename to packages/flutter_image_compress/example/ios/Runner/AppDelegate.h diff --git a/example/ios/Runner/AppDelegate.m b/packages/flutter_image_compress/example/ios/Runner/AppDelegate.m similarity index 100% rename from example/ios/Runner/AppDelegate.m rename to packages/flutter_image_compress/example/ios/Runner/AppDelegate.m diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to packages/flutter_image_compress/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/flutter_image_compress/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to packages/flutter_image_compress/example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/example/ios/Runner/Base.lproj/Main.storyboard b/packages/flutter_image_compress/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from example/ios/Runner/Base.lproj/Main.storyboard rename to packages/flutter_image_compress/example/ios/Runner/Base.lproj/Main.storyboard diff --git a/example/ios/Runner/Info.plist b/packages/flutter_image_compress/example/ios/Runner/Info.plist similarity index 96% rename from example/ios/Runner/Info.plist rename to packages/flutter_image_compress/example/ios/Runner/Info.plist index 2102f2a..bc9336b 100644 --- a/example/ios/Runner/Info.plist +++ b/packages/flutter_image_compress/example/ios/Runner/Info.plist @@ -45,5 +45,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/example/ios/Runner/main.m b/packages/flutter_image_compress/example/ios/Runner/main.m similarity index 100% rename from example/ios/Runner/main.m rename to packages/flutter_image_compress/example/ios/Runner/main.m diff --git a/example/lib/const/resource.dart b/packages/flutter_image_compress/example/lib/const/resource.dart similarity index 100% rename from example/lib/const/resource.dart rename to packages/flutter_image_compress/example/lib/const/resource.dart diff --git a/example/lib/main.dart b/packages/flutter_image_compress/example/lib/main.dart similarity index 87% rename from example/lib/main.dart rename to packages/flutter_image_compress/example/lib/main.dart index 5d77b40..04c2f0f 100644 --- a/example/lib/main.dart +++ b/packages/flutter_image_compress/example/lib/main.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'dart:math' as math; import 'dart:typed_data' as typed_data; +import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -98,7 +99,7 @@ class _MyAppState extends State { return; } safeSetState(() { - provider = FileImage(imgFile); + provider = XFileImageProvider(imgFile); }); } @@ -116,7 +117,7 @@ class _MyAppState extends State { return result; } - Future testCompressAndGetFile(File file, String targetPath) async { + Future testCompressAndGetFile(File file, String targetPath) async { print('testCompressAndGetFile'); final result = await FlutterImageCompress.compressAndGetFile( file.absolute.path, @@ -126,8 +127,15 @@ class _MyAppState extends State { minHeight: 1024, rotate: 90, ); - print(file.lengthSync()); - print(result?.lengthSync()); + + if (result == null) return null; + + final bytes = await result.readAsBytes(); + + print( + 'The src file size: ${file.lengthSync()}, ' + 'the result bytes length: ${bytes.length}', + ); return result; } @@ -249,12 +257,14 @@ class _MyAppState extends State { quality: 90, ); if (result == null) return; + print('Compress heic success.'); logger.logTime(); print('src, path = $srcPath length = ${File(srcPath).lengthSync()}'); + print( - 'Compress heic result path: ${result.absolute.path}, ' - 'size: ${result.lengthSync()}', + 'Compress heic result path: ${result.path}, ' + 'size: ${await result.length()}', ); } @@ -281,11 +291,11 @@ class _MyAppState extends State { logger.logTime(); print('src, path = $srcPath length = ${File(srcPath).lengthSync()}'); print( - 'Compress webp result path: ${result.absolute.path}, ' - 'size: ${result.lengthSync()}', + 'Compress webp result path: ${result.path}, ' + 'size: ${await result.length()}', ); safeSetState(() { - provider = FileImage(result); + provider = XFileImageProvider(result); }); } @@ -452,6 +462,55 @@ class TextButton extends StatelessWidget { @override Widget build(BuildContext context) { - return const Placeholder(); + return Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: onPressed, + child: child, + ), + ); } } + +class XFileImageProvider extends ImageProvider { + const XFileImageProvider(this.file); + + final XFile file; + + @override + Future obtainKey(ImageConfiguration configuration) async { + return this; + } + + Future _loadAsync( + XFileImageProvider key, DecoderBufferCallback decode) async { + final bytes = await file.readAsBytes(); + final buffer = await ui.ImmutableBuffer.fromUint8List(bytes); + return decode(buffer); + } + + @override + ImageStreamCompleter loadBuffer( + XFileImageProvider key, DecoderBufferCallback decode) { + return MultiFrameImageStreamCompleter( + codec: _loadAsync(key, decode), + scale: 1.0, + informationCollector: () sync* { + yield ErrorDescription('Path: ${file.path}'); + }, + ); + } + + @override + bool operator ==(dynamic other) { + if (other.runtimeType != runtimeType) return false; + final XFileImageProvider typedOther = other; + return file.path == typedOther.file.path; + } + + @override + int get hashCode => file.path.hashCode; + + @override + String toString() => '$runtimeType("${file.path}",)'; +} diff --git a/example/lib/main_desktop.dart b/packages/flutter_image_compress/example/lib/main_desktop.dart similarity index 100% rename from example/lib/main_desktop.dart rename to packages/flutter_image_compress/example/lib/main_desktop.dart diff --git a/example/lib/time_logger.dart b/packages/flutter_image_compress/example/lib/time_logger.dart similarity index 100% rename from example/lib/time_logger.dart rename to packages/flutter_image_compress/example/lib/time_logger.dart diff --git a/example/lib/try_catch_example.dart b/packages/flutter_image_compress/example/lib/try_catch_example.dart similarity index 100% rename from example/lib/try_catch_example.dart rename to packages/flutter_image_compress/example/lib/try_catch_example.dart diff --git a/example/pubspec.yaml b/packages/flutter_image_compress/example/pubspec.yaml similarity index 100% rename from example/pubspec.yaml rename to packages/flutter_image_compress/example/pubspec.yaml diff --git a/example/run_hover.sh b/packages/flutter_image_compress/example/run_hover.sh similarity index 100% rename from example/run_hover.sh rename to packages/flutter_image_compress/example/run_hover.sh diff --git a/packages/flutter_image_compress/lib/flutter_image_compress.dart b/packages/flutter_image_compress/lib/flutter_image_compress.dart new file mode 100644 index 0000000..ea70320 --- /dev/null +++ b/packages/flutter_image_compress/lib/flutter_image_compress.dart @@ -0,0 +1,146 @@ +import 'dart:async'; +import 'dart:typed_data' as typed_data; + +import 'package:flutter/services.dart'; +import 'package:flutter_image_compress_platform_interface/flutter_image_compress_platform_interface.dart'; +export 'package:flutter_image_compress_platform_interface/flutter_image_compress_platform_interface.dart'; + +/// Image Compress plugin. +/// +/// Method in the static class will help you to compress images, +/// most methods will return [Uint8List]. +/// +/// You can use `Image.memory` to display image: +/// ```dart +/// Uint8List uint8List; +/// ImageProvider provider = MemoryImage(uint8List); +/// ``` +/// +/// or +/// +/// ```dart +/// Uint8List uint8List; +/// Image.memory(uint8List) +/// ``` +/// +/// The returned image will retain the proportion of the original image. +/// Compress image will remove its EXIF info. and the result is in jpeg format. +/// Rotation is also supported. +class FlutterImageCompress { + static FlutterImageCompressPlatform get _platform => + FlutterImageCompressPlatform.instance; + + static FlutterImageCompressValidator get validator => _platform.validator; + + static set showNativeLog(bool value) { + _platform.showNativeLog(value); + } + + /// Compress image from [Uint8List] to [Uint8List]. + static Future compressWithList( + typed_data.Uint8List image, { + int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + int inSampleSize = 1, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + }) async { + return _platform.compressWithList( + image, + minWidth: minWidth, + minHeight: minHeight, + quality: quality, + rotate: rotate, + inSampleSize: inSampleSize, + autoCorrectionAngle: autoCorrectionAngle, + format: format, + keepExif: keepExif, + ); + } + + /// Compress file of [path] to [Uint8List]. + static Future compressWithFile( + String path, { + int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5, + }) async { + return _platform.compressWithFile( + path, + minWidth: minWidth, + minHeight: minHeight, + quality: quality, + rotate: rotate, + inSampleSize: inSampleSize, + autoCorrectionAngle: autoCorrectionAngle, + format: format, + keepExif: keepExif, + numberOfRetries: numberOfRetries, + ); + } + + /// From [path] to [targetPath] + static Future compressAndGetFile( + String path, + String targetPath, { + int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5, + }) async { + return _platform.compressAndGetFile( + path, + targetPath, + minWidth: minWidth, + minHeight: minHeight, + quality: quality, + rotate: rotate, + inSampleSize: inSampleSize, + autoCorrectionAngle: autoCorrectionAngle, + format: format, + keepExif: keepExif, + numberOfRetries: numberOfRetries, + ); + } + + /// From [asset] to [Uint8List] + static Future compressAssetImage( + String assetName, { + int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + }) async { + return _platform.compressAssetImage( + assetName, + minWidth: minWidth, + minHeight: minHeight, + quality: quality, + rotate: rotate, + autoCorrectionAngle: autoCorrectionAngle, + format: format, + keepExif: keepExif, + ); + } + + static void ignoreCheckSupportPlatform(bool value) { + _platform.ignoreCheckSupportPlatform(value); + } +} diff --git a/packages/flutter_image_compress/pubspec.yaml b/packages/flutter_image_compress/pubspec.yaml new file mode 100644 index 0000000..787fa49 --- /dev/null +++ b/packages/flutter_image_compress/pubspec.yaml @@ -0,0 +1,22 @@ +name: flutter_image_compress +description: Compress Pictures. Can effectively reduce the size of the transmission. +repository: https://github.com/fluttercandies/flutter_image_compress +version: 2.0.0 + +environment: + sdk: '>=2.12.0 <3.0.0' + flutter: '>=2.0.0' + +dependencies: + flutter: + sdk: flutter + flutter_image_compress_platform_interface: ^1.0.0 + flutter_image_compress_common: ^1.0.0 + +flutter: + plugin: + platforms: + android: + default_package: flutter_image_compress_common + ios: + default_package: flutter_image_compress_common diff --git a/packages/flutter_image_compress_common/.gitignore b/packages/flutter_image_compress_common/.gitignore new file mode 100644 index 0000000..40366a1 --- /dev/null +++ b/packages/flutter_image_compress_common/.gitignore @@ -0,0 +1,40 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +*.lock +.env +example/macos/Flutter/ephemeral/flutter_export_environment.sh diff --git a/packages/flutter_image_compress_common/CHANGELOG.md b/packages/flutter_image_compress_common/CHANGELOG.md new file mode 100644 index 0000000..37ffe0d --- /dev/null +++ b/packages/flutter_image_compress_common/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 1.0.0 + +- The first version for migrate to platform interface. diff --git a/packages/flutter_image_compress_common/LICENSE b/packages/flutter_image_compress_common/LICENSE new file mode 100644 index 0000000..09f513b --- /dev/null +++ b/packages/flutter_image_compress_common/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 FlutterCandies + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/flutter_image_compress_common/README.md b/packages/flutter_image_compress_common/README.md new file mode 100644 index 0000000..9a17023 --- /dev/null +++ b/packages/flutter_image_compress_common/README.md @@ -0,0 +1,322 @@ +# flutter_image_compress + +[![ImageCompress](https://img.shields.io/badge/fluttercandies-ImageCompress-blue.svg)](https://github.com/fluttercandies/flutter_image_compress) +[![pub package](https://img.shields.io/pub/v/flutter_image_compress.svg)](https://pub.dartlang.org/packages/flutter_image_compress) +[![GitHub license](https://img.shields.io/github/license/fluttercandies/flutter_image_compress?style=flat-square)](https://github.com/fluttercandies/flutter_image_compress/blob/main/LICENSE) +[![GitHub stars](https://img.shields.io/github/stars/fluttercandies/flutter_image_compress.svg?style=social&label=Stars)](https://github.com/fluttercandies/flutter_image_compress) +[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes) +FlutterCandies + +Compresses image as native plugin (Obj-C/Kotlin). This library works on Android and iOS. + +- [flutter_image_compress](#flutter_image_compress) + - [Why don't you use dart to do it](#why-dont-you-use-dart-to-do-it) + - [Usage](#usage) + - [About common params](#about-common-params) + - [minWidth and minHeight](#minwidth-and-minheight) + - [rotate](#rotate) + - [autoCorrectionAngle](#autocorrectionangle) + - [quality](#quality) + - [format](#format) + - [Webp](#webp) + - [HEIF(Heic)](#heifheic) + - [Heif for iOS](#heif-for-ios) + - [Heif for Android](#heif-for-android) + - [inSampleSize](#insamplesize) + - [keepExif](#keepexif) + - [Result](#result) + - [About `List` and `Uint8List`](#about-listint-and-uint8list) + - [Runtime Error](#runtime-error) + - [Android](#android) + - [Troubleshooting](#troubleshooting) + - [Compressing returns `null`](#compressing-returns-null) + - [About EXIF information](#about-exif-information) + +## Why don't you use dart to do it + +Q:Dart already has image compression libraries. Why use native? + +A:For unknown reasons, image compression in Dart language is not efficient, +even in release version. Using isolate does not solve the problem. + +## Usage + +```yaml +dependencies: + flutter_image_compress: ^1.0.0-nullsafety +``` + +```dart +import 'package:flutter_image_compress/flutter_image_compress.dart'; +``` + +Use as: + +[See full example](https://github.com/fluttercandies/flutter_image_compress/blob/main/example/lib/main.dart) + +There are several ways to use the library api. + +```dart + + // 1. compress file and get Uint8List + Future 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 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 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 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; + } +``` + +## About common params + +### minWidth and minHeight + +`minWidth` and `minHeight` are constraints on image scaling. + +For example, a 4000\*2000 image, `minWidth` set to 1920, +`minHeight` set to 1080, the calculation is as follows: + +```dart +// Using dart as an example, the actual implementation is Kotlin or OC. +import 'dart:math' as math; + +void main() { + var scale = calcScale( + srcWidth: 4000, + srcHeight: 2000, + minWidth: 1920, + minHeight: 1080, + ); + + print("scale = $scale"); // scale = 1.8518518518518519 + print("target width = ${4000 / scale}, height = ${2000 / scale}"); // target width = 2160.0, height = 1080.0 +} + +double calcScale({ + double srcWidth, + double srcHeight, + double minWidth, + double minHeight, +}) { + var scaleW = srcWidth / minWidth; + var scaleH = srcHeight / minHeight; + var scale = math.max(1.0, math.min(scaleW, scaleH)); + return scale; +} +``` + +If your image width is smaller than `minWidth` or height smaller than `minHeight`, +scale will be 1, that is, the size will not change. + +### rotate + +If you need to rotate the picture, use this parameter. + +### autoCorrectionAngle + +This property only exists in the version after 0.5.0. + +And for historical reasons, there may be conflicts with rotate attributes, +which need to be self-corrected. + +Modify rotate to 0 or autoCorrectionAngle to false. + +### quality + +Quality of target image. + +If `format` is png, the param will be ignored in iOS. + +### format + +Supports jpeg or png, default is jpeg. + +The format class sign `enum CompressFormat`. + +Heif and webp Partially supported. + +#### Webp + +Support android by the system api (speed very nice). +The library also supports iOS. However, we're using +[third-party libraries](https://github.com/SDWebImage/SDWebImageWebPCoder), +it is not recommended due to encoding speed. +In the future, `libwebp` by google (C/C++) may be used to do coding work, +bypassing other three-party libraries, but there are no plan for that currently. + +#### HEIF(Heic) + +##### Heif for iOS + +Only support iOS 11+. + +##### Heif for Android + +Use [HeifWriter][] for the implementation. + +Only support API 28+. + +And may require hardware encoder support, +does not guarantee that all devices _above_ API 28 are available. + +[heifwriter]: https://developer.android.com/reference/androidx/heifwriter/HeifWriter.html + +### inSampleSize + +The param is only support android. + +For a description of this parameter, see the [Android official website](https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize). + +### keepExif + +If this parameter is true, EXIF information is saved in the compressed result. + +Attention should be paid to the following points: + +1. Default value is false. +2. Even if set to true, the direction attribute is not included. +3. Only support jpg format, PNG format does not support. + +## Result + +The result of returning a List collection will not have null, but will always be an empty array. + +The returned file may be null. In addition, please decide for yourself whether the file exists. + +### About `List` and `Uint8List` + +You may need to convert `List` to `Uint8List` to display images. + +To use `Uint8List`, you need import package to your code like this: + +![img](https://raw.githubusercontent.com/CaiJingLong/asset_for_picgo/master/20190519111735.png) + +```dart +final image = Uint8List.fromList(imageList); +ImageProvider provider = MemoryImage(Uint8List.fromList(imageList)); +``` + +Usage in `Image` Widget: + +```dart +Future _compressImage() async { + List image = await testCompressFile(file); + ImageProvider provider = MemoryImage(Uint8List.fromList(image)); + imageWidget = Image( + image: provider ?? AssetImage('img/img.jpg'), + ); +} +``` + +Write to file usage: + +```dart +Future writeToFile(List image, String filePath) { + return File(filePath).writeAsBytes(image, flush: true); +} +``` + +## Runtime Error + +Because of some support issues, +all APIs will be compatible with format and system compatibility, +and an exception (`UnsupportedError`) may be thrown, +so if you insist on using webp and heic formats, +please catch the exception yourself and use it on unsupported devices jpeg compression. + +Example: + +```dart +Future compressAndTryCatch(String path) async { + Uint8List result; + try { + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.heic, + ); + } on UnsupportedError catch (e) { + print(e); + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.jpeg, + ); + } + return result; +} +``` + +## Android + +You may need to update Kotlin to version `1.5.21` or higher. + +## Troubleshooting + +### Compressing returns `null` + +Sometimes, compressing will return null. You should check if you can read/write the file, +and the parent folder of the target file must exist. + +For example, use the [path_provider](https://pub.dartlang.org/packages/path_provide) +plugin to access some application folders, +and use a permission plugin to request permission to access SD cards on Android/iOS. + +## About EXIF information + +Using this library, EXIF information will be removed by default. + +EXIF information can be retained by setting keepExif to true, +but not `direction` information. + +- PNG/JPEG encoder: System API. +- WebP encoder: + - [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) on iOS. + - System API on Android. +- HEIF encoder: System API. + - [HeifWriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) on Android P+. diff --git a/analysis_options.yaml b/packages/flutter_image_compress_common/analysis_options.yaml similarity index 100% rename from analysis_options.yaml rename to packages/flutter_image_compress_common/analysis_options.yaml diff --git a/example/android/.gitignore b/packages/flutter_image_compress_common/android/.gitignore similarity index 100% rename from example/android/.gitignore rename to packages/flutter_image_compress_common/android/.gitignore diff --git a/android/build.gradle b/packages/flutter_image_compress_common/android/build.gradle similarity index 100% rename from android/build.gradle rename to packages/flutter_image_compress_common/android/build.gradle diff --git a/android/gradle.properties b/packages/flutter_image_compress_common/android/gradle.properties similarity index 100% rename from android/gradle.properties rename to packages/flutter_image_compress_common/android/gradle.properties diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/packages/flutter_image_compress_common/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from android/gradle/wrapper/gradle-wrapper.properties rename to packages/flutter_image_compress_common/android/gradle/wrapper/gradle-wrapper.properties diff --git a/android/settings.gradle b/packages/flutter_image_compress_common/android/settings.gradle similarity index 100% rename from android/settings.gradle rename to packages/flutter_image_compress_common/android/settings.gradle diff --git a/android/src/main/AndroidManifest.xml b/packages/flutter_image_compress_common/android/src/main/AndroidManifest.xml similarity index 100% rename from android/src/main/AndroidManifest.xml rename to packages/flutter_image_compress_common/android/src/main/AndroidManifest.xml diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ImageCompressPlugin.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ImageCompressPlugin.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ImageCompressPlugin.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ImageCompressPlugin.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressFileHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressFileHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressFileHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressFileHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressListHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressListHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressListHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/CompressListHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/ResultHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/ResultHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/ResultHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/core/ResultHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exception/CompressError.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exception/CompressError.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exception/CompressError.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exception/CompressError.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/Exif.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/Exif.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/Exif.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/Exif.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/ExifKeeper.java b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/ExifKeeper.java similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/ExifKeeper.java rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/exif/ExifKeeper.java diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ext/BitmapCompressExt.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ext/BitmapCompressExt.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ext/BitmapCompressExt.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/ext/BitmapCompressExt.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/format/FormatRegister.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/format/FormatRegister.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/format/FormatRegister.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/format/FormatRegister.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/FormatHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/FormatHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/FormatHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/FormatHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/common/CommonHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/common/CommonHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/common/CommonHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/common/CommonHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/heif/HeifHandler.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/heif/HeifHandler.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/heif/HeifHandler.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/handle/heif/HeifHandler.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/logger/LogExt.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/logger/LogExt.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/logger/LogExt.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/logger/LogExt.kt diff --git a/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/util/TmpFileUtil.kt b/packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/util/TmpFileUtil.kt similarity index 100% rename from android/src/main/kotlin/com/fluttercandies/flutter_image_compress/util/TmpFileUtil.kt rename to packages/flutter_image_compress_common/android/src/main/kotlin/com/fluttercandies/flutter_image_compress/util/TmpFileUtil.kt diff --git a/go/README.md b/packages/flutter_image_compress_common/go/README.md similarity index 100% rename from go/README.md rename to packages/flutter_image_compress_common/go/README.md diff --git a/go/compress.go b/packages/flutter_image_compress_common/go/compress.go similarity index 100% rename from go/compress.go rename to packages/flutter_image_compress_common/go/compress.go diff --git a/go/dlib/README.md b/packages/flutter_image_compress_common/go/dlib/README.md similarity index 100% rename from go/dlib/README.md rename to packages/flutter_image_compress_common/go/dlib/README.md diff --git a/go/go.mod b/packages/flutter_image_compress_common/go/go.mod similarity index 100% rename from go/go.mod rename to packages/flutter_image_compress_common/go/go.mod diff --git a/go/go.sum b/packages/flutter_image_compress_common/go/go.sum similarity index 100% rename from go/go.sum rename to packages/flutter_image_compress_common/go/go.sum diff --git a/go/import.go.tmpl b/packages/flutter_image_compress_common/go/import.go.tmpl similarity index 100% rename from go/import.go.tmpl rename to packages/flutter_image_compress_common/go/import.go.tmpl diff --git a/go/plugin.go b/packages/flutter_image_compress_common/go/plugin.go similarity index 100% rename from go/plugin.go rename to packages/flutter_image_compress_common/go/plugin.go diff --git a/ios/.gitignore b/packages/flutter_image_compress_common/ios/.gitignore similarity index 100% rename from ios/.gitignore rename to packages/flutter_image_compress_common/ios/.gitignore diff --git a/ios/Assets/.gitkeep b/packages/flutter_image_compress_common/ios/Assets/.gitkeep similarity index 100% rename from ios/Assets/.gitkeep rename to packages/flutter_image_compress_common/ios/Assets/.gitkeep diff --git a/ios/Classes/CompressFileHandler.h b/packages/flutter_image_compress_common/ios/Classes/CompressFileHandler.h similarity index 100% rename from ios/Classes/CompressFileHandler.h rename to packages/flutter_image_compress_common/ios/Classes/CompressFileHandler.h diff --git a/ios/Classes/CompressFileHandler.m b/packages/flutter_image_compress_common/ios/Classes/CompressFileHandler.m similarity index 100% rename from ios/Classes/CompressFileHandler.m rename to packages/flutter_image_compress_common/ios/Classes/CompressFileHandler.m diff --git a/ios/Classes/CompressHandler.h b/packages/flutter_image_compress_common/ios/Classes/CompressHandler.h similarity index 100% rename from ios/Classes/CompressHandler.h rename to packages/flutter_image_compress_common/ios/Classes/CompressHandler.h diff --git a/ios/Classes/CompressHandler.m b/packages/flutter_image_compress_common/ios/Classes/CompressHandler.m similarity index 100% rename from ios/Classes/CompressHandler.m rename to packages/flutter_image_compress_common/ios/Classes/CompressHandler.m diff --git a/ios/Classes/CompressListHandler.h b/packages/flutter_image_compress_common/ios/Classes/CompressListHandler.h similarity index 100% rename from ios/Classes/CompressListHandler.h rename to packages/flutter_image_compress_common/ios/Classes/CompressListHandler.h diff --git a/ios/Classes/CompressListHandler.m b/packages/flutter_image_compress_common/ios/Classes/CompressListHandler.m similarity index 100% rename from ios/Classes/CompressListHandler.m rename to packages/flutter_image_compress_common/ios/Classes/CompressListHandler.m diff --git a/ios/Classes/ImageCompressPlugin.h b/packages/flutter_image_compress_common/ios/Classes/ImageCompressPlugin.h similarity index 100% rename from ios/Classes/ImageCompressPlugin.h rename to packages/flutter_image_compress_common/ios/Classes/ImageCompressPlugin.h diff --git a/ios/Classes/ImageCompressPlugin.m b/packages/flutter_image_compress_common/ios/Classes/ImageCompressPlugin.m similarity index 100% rename from ios/Classes/ImageCompressPlugin.m rename to packages/flutter_image_compress_common/ios/Classes/ImageCompressPlugin.m diff --git a/ios/Classes/SYPictureMetadata/NSDictionary+SY.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/NSDictionary+SY.h similarity index 100% rename from ios/Classes/SYPictureMetadata/NSDictionary+SY.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/NSDictionary+SY.h diff --git a/ios/Classes/SYPictureMetadata/NSDictionary+SY.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/NSDictionary+SY.m similarity index 100% rename from ios/Classes/SYPictureMetadata/NSDictionary+SY.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/NSDictionary+SY.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadata.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadata.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadata.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadata.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadata8BIM.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata8BIM.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadata8BIM.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata8BIM.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadata8BIM.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata8BIM.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadata8BIM.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata8BIM.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataBase.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataBase.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataBase.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataBase.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataBase.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataBase.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataBase.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataBase.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataCIFF.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataCIFF.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataCIFF.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataCIFF.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataCIFF.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataCIFF.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataCIFF.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataCIFF.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataDNG.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataDNG.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataDNG.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataDNG.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataDNG.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataDNG.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataDNG.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataDNG.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataExif.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExif.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataExif.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExif.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataExif.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExif.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataExif.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExif.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataExifAux.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExifAux.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataExifAux.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExifAux.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataExifAux.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExifAux.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataExifAux.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataExifAux.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataGIF.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGIF.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataGIF.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGIF.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataGIF.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGIF.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataGIF.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGIF.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataGPS.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGPS.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataGPS.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGPS.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataGPS.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGPS.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataGPS.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataGPS.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataIPTC.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTC.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataIPTC.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTC.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataIPTC.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTC.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataIPTC.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTC.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataIPTCContactInfo.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataJFIF.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataJFIF.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataJFIF.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataJFIF.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataJFIF.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataJFIF.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataJFIF.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataJFIF.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerCanon.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerFuji.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerMinolta.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerNikon.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerOlympus.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataMakerPentax.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataPNG.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataPNG.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataPNG.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataPNG.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataPNG.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataPNG.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataPNG.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataPNG.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataRaw.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataRaw.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataRaw.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataRaw.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataRaw.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataRaw.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataRaw.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataRaw.m diff --git a/ios/Classes/SYPictureMetadata/SYMetadataTIFF.h b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataTIFF.h similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataTIFF.h rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataTIFF.h diff --git a/ios/Classes/SYPictureMetadata/SYMetadataTIFF.m b/packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataTIFF.m similarity index 100% rename from ios/Classes/SYPictureMetadata/SYMetadataTIFF.m rename to packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadataTIFF.m diff --git a/ios/Classes/UIImage+scale.h b/packages/flutter_image_compress_common/ios/Classes/UIImage+scale.h similarity index 100% rename from ios/Classes/UIImage+scale.h rename to packages/flutter_image_compress_common/ios/Classes/UIImage+scale.h diff --git a/ios/Classes/UIImage+scale.m b/packages/flutter_image_compress_common/ios/Classes/UIImage+scale.m similarity index 100% rename from ios/Classes/UIImage+scale.m rename to packages/flutter_image_compress_common/ios/Classes/UIImage+scale.m diff --git a/ios/flutter_image_compress.podspec b/packages/flutter_image_compress_common/ios/flutter_image_compress_common.podspec similarity index 92% rename from ios/flutter_image_compress.podspec rename to packages/flutter_image_compress_common/ios/flutter_image_compress_common.podspec index 1827493..4b938c0 100644 --- a/ios/flutter_image_compress.podspec +++ b/packages/flutter_image_compress_common/ios/flutter_image_compress_common.podspec @@ -1,5 +1,5 @@ Pod::Spec.new do |s| - s.name = 'flutter_image_compress' + s.name = 'flutter_image_compress_common' s.version = '1.0.0' s.summary = 'Compress image with native Objective-C with faster speed.' s.description = <<-DESC diff --git a/lib/flutter_image_compress.dart b/packages/flutter_image_compress_common/lib/flutter_image_compress_common.dart similarity index 72% rename from lib/flutter_image_compress.dart rename to packages/flutter_image_compress_common/lib/flutter_image_compress_common.dart index 9ef4886..3085f62 100644 --- a/lib/flutter_image_compress.dart +++ b/packages/flutter_image_compress_common/lib/flutter_image_compress_common.dart @@ -1,15 +1,12 @@ +// ignore_for_file: require_trailing_commas + import 'dart:async'; import 'dart:io'; import 'dart:typed_data' as typed_data; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - -import 'src/compress_format.dart'; -import 'src/errors.dart'; -import 'src/validator.dart'; - -export 'src/compress_format.dart'; +import 'package:flutter_image_compress_platform_interface/flutter_image_compress_platform_interface.dart'; /// Image Compress plugin. /// @@ -32,51 +29,54 @@ export 'src/compress_format.dart'; /// The returned image will retain the proportion of the original image. /// Compress image will remove its EXIF info. and the result is in jpeg format. /// Rotation is also supported. -class FlutterImageCompress { +class FlutterImageCompressCommon extends FlutterImageCompressPlatform { static const _channel = MethodChannel('flutter_image_compress'); - static Validator get validator => _validator; - static final Validator _validator = Validator(_channel); + @override + FlutterImageCompressValidator get validator => _validator; + final FlutterImageCompressValidator _validator = + FlutterImageCompressValidator(_channel); - static set showNativeLog(bool value) { - _channel.invokeMethod('showLog', value); + /// For flutter plugin registration. + static void registerWith() { + FlutterImageCompressPlatform.instance = FlutterImageCompressCommon(); } - /// Compress image from [Uint8List] to [Uint8List]. - static Future compressWithList( - typed_data.Uint8List image, { - int minWidth = 1920, - int minHeight = 1080, - int quality = 95, - int rotate = 0, - int inSampleSize = 1, - bool autoCorrectionAngle = true, - CompressFormat format = CompressFormat.jpeg, - bool keepExif = false, - }) async { - if (image.isEmpty) { - throw CompressError('The image is empty.'); - } + @override + Future compressAssetImage(String assetName, + {int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false}) async { final support = await _validator.checkSupportPlatform(format); if (!support) { - throw UnsupportedError('The image type $format is not supported.'); + return null; } - final result = await _channel.invokeMethod('compressWithList', [ - image, - minWidth, - minHeight, - quality, - rotate, - autoCorrectionAngle, - _convertTypeToInt(format), - keepExif, - inSampleSize, - ]); - return result; + final img = AssetImage(assetName); + const config = ImageConfiguration(); + final AssetBundleImageKey key = await img.obtainKey(config); + final ByteData data = await key.bundle.load(key.name); + final uint8List = data.buffer.asUint8List(); + if (uint8List.isEmpty) { + return null; + } + return compressWithList( + uint8List, + minHeight: minHeight, + minWidth: minWidth, + quality: quality, + rotate: rotate, + autoCorrectionAngle: autoCorrectionAngle, + format: format, + keepExif: keepExif, + ); } - /// Compress file of [path] to [Uint8List]. - static Future compressWithFile( + @override + Future compressWithFile( String path, { int minWidth = 1920, int minHeight = 1080, @@ -113,8 +113,44 @@ class FlutterImageCompress { return result; } - /// From [path] to [targetPath] - static Future compressAndGetFile( + @override + Future compressWithList(typed_data.Uint8List image, + {int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + int inSampleSize = 1, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false}) async { + if (image.isEmpty) { + throw CompressError('The image is empty.'); + } + final support = await _validator.checkSupportPlatform(format); + if (!support) { + throw UnsupportedError('The image type $format is not supported.'); + } + final result = await _channel.invokeMethod('compressWithList', [ + image, + minWidth, + minHeight, + quality, + rotate, + autoCorrectionAngle, + _convertTypeToInt(format), + keepExif, + inSampleSize, + ]); + return result; + } + + @override + Future showNativeLog(bool value) async { + await _channel.invokeMethod('showLog', value); + } + + @override + Future compressAndGetFile( String path, String targetPath, { int minWidth = 1920, @@ -160,42 +196,12 @@ class FlutterImageCompress { if (result == null) { return null; } - return File(result); + return XFile(result); } - /// From [asset] to [Uint8List] - static Future compressAssetImage( - String assetName, { - int minWidth = 1920, - int minHeight = 1080, - int quality = 95, - int rotate = 0, - bool autoCorrectionAngle = true, - CompressFormat format = CompressFormat.jpeg, - bool keepExif = false, - }) async { - final support = await _validator.checkSupportPlatform(format); - if (!support) { - return null; - } - final img = AssetImage(assetName); - const config = ImageConfiguration(); - final AssetBundleImageKey key = await img.obtainKey(config); - final ByteData data = await key.bundle.load(key.name); - final uint8List = data.buffer.asUint8List(); - if (uint8List.isEmpty) { - return null; - } - return compressWithList( - uint8List, - minHeight: minHeight, - minWidth: minWidth, - quality: quality, - rotate: rotate, - autoCorrectionAngle: autoCorrectionAngle, - format: format, - keepExif: keepExif, - ); + @override + void ignoreCheckSupportPlatform(bool value) { + _validator.ignoreCheckSupportPlatform = value; } } diff --git a/packages/flutter_image_compress_common/pubspec.yaml b/packages/flutter_image_compress_common/pubspec.yaml new file mode 100644 index 0000000..7e6fee6 --- /dev/null +++ b/packages/flutter_image_compress_common/pubspec.yaml @@ -0,0 +1,25 @@ +name: flutter_image_compress_common +description: Compress image with native (Objective-C/Kotlin) with faster speed. Support Android/iOS. +repository: https://github.com/fluttercandies/flutter_image_compress +version: 1.0.0 + +environment: + sdk: '>=2.12.0 <3.0.0' + flutter: '>=2.0.0' + +dependencies: + flutter: + sdk: flutter + flutter_image_compress_platform_interface: ^1.0.0 + +flutter: + plugin: + implements: flutter_image_compress + platforms: + android: + package: com.fluttercandies.flutter_image_compress + pluginClass: ImageCompressPlugin + dartPluginClass: FlutterImageCompressCommon + ios: + pluginClass: ImageCompressPlugin + dartPluginClass: FlutterImageCompressCommon diff --git a/packages/flutter_image_compress_platform_interface/.gitignore b/packages/flutter_image_compress_platform_interface/.gitignore new file mode 100644 index 0000000..40366a1 --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/.gitignore @@ -0,0 +1,40 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +*.lock +.env +example/macos/Flutter/ephemeral/flutter_export_environment.sh diff --git a/packages/flutter_image_compress_platform_interface/CHANGELOG.md b/packages/flutter_image_compress_platform_interface/CHANGELOG.md new file mode 100644 index 0000000..37ffe0d --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 1.0.0 + +- The first version for migrate to platform interface. diff --git a/packages/flutter_image_compress_platform_interface/LICENSE b/packages/flutter_image_compress_platform_interface/LICENSE new file mode 100644 index 0000000..09f513b --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 FlutterCandies + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/flutter_image_compress_platform_interface/README.md b/packages/flutter_image_compress_platform_interface/README.md new file mode 100644 index 0000000..9a17023 --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/README.md @@ -0,0 +1,322 @@ +# flutter_image_compress + +[![ImageCompress](https://img.shields.io/badge/fluttercandies-ImageCompress-blue.svg)](https://github.com/fluttercandies/flutter_image_compress) +[![pub package](https://img.shields.io/pub/v/flutter_image_compress.svg)](https://pub.dartlang.org/packages/flutter_image_compress) +[![GitHub license](https://img.shields.io/github/license/fluttercandies/flutter_image_compress?style=flat-square)](https://github.com/fluttercandies/flutter_image_compress/blob/main/LICENSE) +[![GitHub stars](https://img.shields.io/github/stars/fluttercandies/flutter_image_compress.svg?style=social&label=Stars)](https://github.com/fluttercandies/flutter_image_compress) +[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes) +FlutterCandies + +Compresses image as native plugin (Obj-C/Kotlin). This library works on Android and iOS. + +- [flutter_image_compress](#flutter_image_compress) + - [Why don't you use dart to do it](#why-dont-you-use-dart-to-do-it) + - [Usage](#usage) + - [About common params](#about-common-params) + - [minWidth and minHeight](#minwidth-and-minheight) + - [rotate](#rotate) + - [autoCorrectionAngle](#autocorrectionangle) + - [quality](#quality) + - [format](#format) + - [Webp](#webp) + - [HEIF(Heic)](#heifheic) + - [Heif for iOS](#heif-for-ios) + - [Heif for Android](#heif-for-android) + - [inSampleSize](#insamplesize) + - [keepExif](#keepexif) + - [Result](#result) + - [About `List` and `Uint8List`](#about-listint-and-uint8list) + - [Runtime Error](#runtime-error) + - [Android](#android) + - [Troubleshooting](#troubleshooting) + - [Compressing returns `null`](#compressing-returns-null) + - [About EXIF information](#about-exif-information) + +## Why don't you use dart to do it + +Q:Dart already has image compression libraries. Why use native? + +A:For unknown reasons, image compression in Dart language is not efficient, +even in release version. Using isolate does not solve the problem. + +## Usage + +```yaml +dependencies: + flutter_image_compress: ^1.0.0-nullsafety +``` + +```dart +import 'package:flutter_image_compress/flutter_image_compress.dart'; +``` + +Use as: + +[See full example](https://github.com/fluttercandies/flutter_image_compress/blob/main/example/lib/main.dart) + +There are several ways to use the library api. + +```dart + + // 1. compress file and get Uint8List + Future 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 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 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 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; + } +``` + +## About common params + +### minWidth and minHeight + +`minWidth` and `minHeight` are constraints on image scaling. + +For example, a 4000\*2000 image, `minWidth` set to 1920, +`minHeight` set to 1080, the calculation is as follows: + +```dart +// Using dart as an example, the actual implementation is Kotlin or OC. +import 'dart:math' as math; + +void main() { + var scale = calcScale( + srcWidth: 4000, + srcHeight: 2000, + minWidth: 1920, + minHeight: 1080, + ); + + print("scale = $scale"); // scale = 1.8518518518518519 + print("target width = ${4000 / scale}, height = ${2000 / scale}"); // target width = 2160.0, height = 1080.0 +} + +double calcScale({ + double srcWidth, + double srcHeight, + double minWidth, + double minHeight, +}) { + var scaleW = srcWidth / minWidth; + var scaleH = srcHeight / minHeight; + var scale = math.max(1.0, math.min(scaleW, scaleH)); + return scale; +} +``` + +If your image width is smaller than `minWidth` or height smaller than `minHeight`, +scale will be 1, that is, the size will not change. + +### rotate + +If you need to rotate the picture, use this parameter. + +### autoCorrectionAngle + +This property only exists in the version after 0.5.0. + +And for historical reasons, there may be conflicts with rotate attributes, +which need to be self-corrected. + +Modify rotate to 0 or autoCorrectionAngle to false. + +### quality + +Quality of target image. + +If `format` is png, the param will be ignored in iOS. + +### format + +Supports jpeg or png, default is jpeg. + +The format class sign `enum CompressFormat`. + +Heif and webp Partially supported. + +#### Webp + +Support android by the system api (speed very nice). +The library also supports iOS. However, we're using +[third-party libraries](https://github.com/SDWebImage/SDWebImageWebPCoder), +it is not recommended due to encoding speed. +In the future, `libwebp` by google (C/C++) may be used to do coding work, +bypassing other three-party libraries, but there are no plan for that currently. + +#### HEIF(Heic) + +##### Heif for iOS + +Only support iOS 11+. + +##### Heif for Android + +Use [HeifWriter][] for the implementation. + +Only support API 28+. + +And may require hardware encoder support, +does not guarantee that all devices _above_ API 28 are available. + +[heifwriter]: https://developer.android.com/reference/androidx/heifwriter/HeifWriter.html + +### inSampleSize + +The param is only support android. + +For a description of this parameter, see the [Android official website](https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize). + +### keepExif + +If this parameter is true, EXIF information is saved in the compressed result. + +Attention should be paid to the following points: + +1. Default value is false. +2. Even if set to true, the direction attribute is not included. +3. Only support jpg format, PNG format does not support. + +## Result + +The result of returning a List collection will not have null, but will always be an empty array. + +The returned file may be null. In addition, please decide for yourself whether the file exists. + +### About `List` and `Uint8List` + +You may need to convert `List` to `Uint8List` to display images. + +To use `Uint8List`, you need import package to your code like this: + +![img](https://raw.githubusercontent.com/CaiJingLong/asset_for_picgo/master/20190519111735.png) + +```dart +final image = Uint8List.fromList(imageList); +ImageProvider provider = MemoryImage(Uint8List.fromList(imageList)); +``` + +Usage in `Image` Widget: + +```dart +Future _compressImage() async { + List image = await testCompressFile(file); + ImageProvider provider = MemoryImage(Uint8List.fromList(image)); + imageWidget = Image( + image: provider ?? AssetImage('img/img.jpg'), + ); +} +``` + +Write to file usage: + +```dart +Future writeToFile(List image, String filePath) { + return File(filePath).writeAsBytes(image, flush: true); +} +``` + +## Runtime Error + +Because of some support issues, +all APIs will be compatible with format and system compatibility, +and an exception (`UnsupportedError`) may be thrown, +so if you insist on using webp and heic formats, +please catch the exception yourself and use it on unsupported devices jpeg compression. + +Example: + +```dart +Future compressAndTryCatch(String path) async { + Uint8List result; + try { + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.heic, + ); + } on UnsupportedError catch (e) { + print(e); + result = await FlutterImageCompress.compressWithFile( + path, + format: CompressFormat.jpeg, + ); + } + return result; +} +``` + +## Android + +You may need to update Kotlin to version `1.5.21` or higher. + +## Troubleshooting + +### Compressing returns `null` + +Sometimes, compressing will return null. You should check if you can read/write the file, +and the parent folder of the target file must exist. + +For example, use the [path_provider](https://pub.dartlang.org/packages/path_provide) +plugin to access some application folders, +and use a permission plugin to request permission to access SD cards on Android/iOS. + +## About EXIF information + +Using this library, EXIF information will be removed by default. + +EXIF information can be retained by setting keepExif to true, +but not `direction` information. + +- PNG/JPEG encoder: System API. +- WebP encoder: + - [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) on iOS. + - System API on Android. +- HEIF encoder: System API. + - [HeifWriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) on Android P+. diff --git a/packages/flutter_image_compress_platform_interface/lib/flutter_image_compress_platform_interface.dart b/packages/flutter_image_compress_platform_interface/lib/flutter_image_compress_platform_interface.dart new file mode 100644 index 0000000..bd7ecfc --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/lib/flutter_image_compress_platform_interface.dart @@ -0,0 +1,144 @@ +import 'package:cross_file/cross_file.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'dart:typed_data' as typed_data; + +import 'src/compress_format.dart'; +import 'src/validator.dart'; + +export 'src/compress_format.dart'; +export 'src/errors.dart'; +export 'src/validator.dart'; +export 'package:cross_file/cross_file.dart'; + +abstract class FlutterImageCompressPlatform extends PlatformInterface { + static const _token = Object(); + + static FlutterImageCompressPlatform instance = + UnsupportedFlutterImageCompress(); + + FlutterImageCompressPlatform() : super(token: _token); + + FlutterImageCompressValidator get validator; + + Future showNativeLog(bool value); + + Future compressWithList( + typed_data.Uint8List image, { + int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + int inSampleSize = 1, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + }); + + Future compressWithFile( + String path, { + int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5, + }); + + Future compressAndGetFile( + String path, + String targetPath, { + int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5, + }); + + Future compressAssetImage( + String assetName, { + int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + }); + + void ignoreCheckSupportPlatform(bool bool); +} + +class UnsupportedFlutterImageCompress extends FlutterImageCompressPlatform { + @override + Future compressAssetImage(String assetName, + {int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false}) { + throw UnimplementedError(); + } + + @override + Future compressWithFile(String path, + {int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5}) { + throw UnimplementedError(); + } + + @override + Future compressAndGetFile(String path, String targetPath, + {int minWidth = 1920, + int minHeight = 1080, + int inSampleSize = 1, + int quality = 95, + int rotate = 0, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false, + int numberOfRetries = 5}) { + throw UnimplementedError(); + } + + @override + Future compressWithList(typed_data.Uint8List image, + {int minWidth = 1920, + int minHeight = 1080, + int quality = 95, + int rotate = 0, + int inSampleSize = 1, + bool autoCorrectionAngle = true, + CompressFormat format = CompressFormat.jpeg, + bool keepExif = false}) { + throw UnimplementedError(); + } + + @override + Future showNativeLog(bool value) { + throw UnimplementedError(); + } + + @override + void ignoreCheckSupportPlatform(bool bool) { + throw UnimplementedError(); + } + + @override + FlutterImageCompressValidator get validator => throw UnimplementedError(); +} diff --git a/lib/src/compress_format.dart b/packages/flutter_image_compress_platform_interface/lib/src/compress_format.dart similarity index 100% rename from lib/src/compress_format.dart rename to packages/flutter_image_compress_platform_interface/lib/src/compress_format.dart diff --git a/lib/src/errors.dart b/packages/flutter_image_compress_platform_interface/lib/src/errors.dart similarity index 100% rename from lib/src/errors.dart rename to packages/flutter_image_compress_platform_interface/lib/src/errors.dart diff --git a/lib/src/validator.dart b/packages/flutter_image_compress_platform_interface/lib/src/validator.dart similarity index 96% rename from lib/src/validator.dart rename to packages/flutter_image_compress_platform_interface/lib/src/validator.dart index 51c42b4..47993d3 100644 --- a/lib/src/validator.dart +++ b/packages/flutter_image_compress_platform_interface/lib/src/validator.dart @@ -5,8 +5,8 @@ import 'package:flutter/services.dart'; import 'compress_format.dart'; -class Validator { - Validator(this.channel); +class FlutterImageCompressValidator { + FlutterImageCompressValidator(this.channel); final MethodChannel channel; diff --git a/packages/flutter_image_compress_platform_interface/pubspec.yaml b/packages/flutter_image_compress_platform_interface/pubspec.yaml new file mode 100644 index 0000000..d85f65b --- /dev/null +++ b/packages/flutter_image_compress_platform_interface/pubspec.yaml @@ -0,0 +1,14 @@ +name: flutter_image_compress_platform_interface +description: The platform interface of flutter_image_compress. +repository: https://github.com/fluttercandies/flutter_image_compress +version: 1.0.0 + +environment: + sdk: '>=2.12.0 <3.0.0' + flutter: '>=2.0.0' + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.0 + cross_file: ^0.3.3+2 \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..b6892db --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,317 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + ansi_styles: + dependency: transitive + description: + name: ansi_styles + sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.2+1" + args: + dependency: transitive + description: + name: args + sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" + cli_launcher: + dependency: transitive + description: + name: cli_launcher + sha256: "5e7e0282b79e8642edd6510ee468ae2976d847a0a29b3916e85f5fa1bfe24005" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.1" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.5" + collection: + dependency: transitive + description: + name: collection + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.17.1" + conventional_commit: + dependency: transitive + description: + name: conventional_commit + sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0+1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.4" + glob: + dependency: transitive + description: + name: glob + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + graphs: + dependency: transitive + description: + name: graphs + sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + http: + dependency: transitive + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.13.6" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.4" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.8.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.15" + melos: + dependency: "direct dev" + description: + name: melos + sha256: "993ac467e7a36bd832a6cdabbe18a0487c30bc52b5cca14e476a824679ebdce0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + mustache_template: + dependency: transitive + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.8.3" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.2.4" + prompts: + dependency: transitive + description: + name: prompts + sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.3" + pub_updater: + dependency: transitive + description: + name: pub_updater + sha256: "42890302ab2672adf567dc2b20e55b4ecc29d7e19c63b6b98143ab68dd717d3a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.4" + pubspec: + dependency: transitive + description: + name: pubspec + sha256: f534a50a2b4d48dc3bc0ec147c8bd7c304280fff23b153f3f11803c4d49d927e + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.1" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" + uri: + dependency: transitive + description: + name: uri + sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.1" + yaml_edit: + dependency: transitive + description: + name: yaml_edit + sha256: "1579d4a0340a83cf9e4d580ea51a16329c916973bffd5bd4b45e911b25d46bfd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" +sdks: + dart: ">=2.19.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index e5513af..bfe5ece 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,21 +1,6 @@ -name: flutter_image_compress -description: Compress image with native (Objective-C/Kotlin) with faster speed. Support Android/iOS. -repository: https://github.com/fluttercandies/flutter_image_compress -version: 1.1.3 +name: flutter_image_compress_workspace environment: - sdk: '>=2.12.0 <3.0.0' - flutter: '>=2.0.0' - -dependencies: - flutter: - sdk: flutter - -flutter: - plugin: - platforms: - android: - package: com.fluttercandies.flutter_image_compress - pluginClass: ImageCompressPlugin - ios: - pluginClass: ImageCompressPlugin + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + melos: ^3.0.1