flutter_native_image_v2
v1.1.5+1A flutter plugin which uses native iOS/Android to resize, compress or crop
Архив пакета: https://pubdev.letsnova.ru/api/archives/flutter_native_image_v2/1.1.5+1.tar.gz
dart pub add flutter_native_image_v2README
Flutter Native Image v2
This project is a fork of the original flutter_native_image by @btastic. The original repository has been archived, as its author decided to move on from the project due to time constraints and shifting priorities.
What's New in This Fork?
This fork, Flutter Native Image v2, is updated to support the latest version of Flutter and ensure compatibility with modern Flutter projects. The following updates have been made:
- Upgraded to work seamlessly with Flutter v3.27.1.
- Fixed issues and updated dependencies for better compatibility.
- Plans for ongoing maintenance and enhancements.
Acknowledgements
We thank the original author and contributors of flutter_native_image for their efforts in creating this library, which has been widely used and appreciated by the Flutter community.
flutter_native_image_v2
Native Flutter Image tools
This plugin aims to have native tools to resize images and reduce their quality by compression. The code is somewhat hacky (especially the iOS part), but it works for my needs and hasn't crashed on me. Feel free to improve it if you want to.
Right now there are a few functions. Please find some examples below.
Usage
Install
Add the following lines to your pubspec.yaml under dependencies
flutter_native_image: ^0.0.6
Compress an image
File compressedFile = await FlutterNativeImage.compressImage(file.path,
quality: quality, percentage: percentage);
You have to give it a file from the file system and optionally provide a quality (1-100) and a resizing percentage (1-100). Each platform will use it's proper tools to handle the resizing.
To resize the image to the certain size, use following code:
ImageProperties properties = await FlutterNativeImage.getImageProperties(file.path);
File compressedFile = await FlutterNativeImage.compressImage(file.path, quality: 80,
targetWidth: 600, targetHeight: 300);
Keep aspect ratio of the file:
ImageProperties properties = await FlutterNativeImage.getImageProperties(file.path);
File compressedFile = await FlutterNativeImage.compressImage(file.path, quality: 80,
targetWidth: 600,
targetHeight: (properties.height * 600 / properties.width).round());
Get image properties
ImageProperties properties = await FlutterNativeImage.getImageProperties(file.path);
It returns an ImageProperties object containing the width and the height of the image.
Crop an image
File croppedFile = await FlutterNativeImage.cropImage(file.path, originX, originY, width, height);
Returns a file containing the image cropped with the given dimensions.
Contributions
Alexis Leblond (a-leblond) the image properties feature.
Eugene Strokin the resize to target height/width feature
Dae Won Kim null-safety feature
Credits
Shoutouts to Trevor from Vocaro.com. He had the fitting algorithm for resizing images in Objective-C.
Source: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
For preserving exif information, I took the code from googles image_picker github (https://github.com/flutter/plugins/tree/master/packages/image_picker)
История изменений
[1.1.5+1]
- Bumped package version to 1.1.5+1.
- To be compatible with latest Gradle versions,
namespaceattribute must be added to Gradle file #1. - Thanks to @isandoqa.
[1.1.3]
- Improved stability and performance
- Code cleanup and documentation updates
- Maintenance release with minor bug fixes
[1.1.2+4]
- CRITICAL FIX: Fixed MissingPluginException by correcting method channel name mismatch
- Updated Android implementation to use correct channel name 'flutter_native_image_v2'
- Updated iOS implementation to use correct channel name 'flutter_native_image_v2'
- Resolved issue where compressImage method was not found on channel flutter_native_image_v2
[1.0.1]
- Updated package for Flutter 3.32.8 compatibility.
- Fixed namespace configuration for Android Gradle Plugin compatibility.
- Updated Android Gradle Plugin to version 7.3.0 and Gradle to 7.5.
- Removed deprecated Flutter embedding APIs and updated to modern Flutter plugin architecture.
- Updated minimum SDK versions and compilation targets for better compatibility.
- Replaced deprecated repositories (jcenter) with mavenCentral.
[1.1.0+3]
- BREAKING: Updated for Flutter 3.32.8 compatibility
- Fixed namespace issues with Android Gradle Plugin 7.3.0
- Removed deprecated
registerWithmethod - now uses modern Flutter embedding v2 only - Updated Android
compileSdkVersionto 34 andminSdkVersionto 21 - Replaced deprecated
getDartExecutor()withgetBinaryMessenger() - Updated Gradle wrapper to 7.5 for better compatibility
- Replaced deprecated
jcenter()withmavenCentral() - Updated minimum Flutter version requirement to 3.16.0
- Fixed Java compilation errors with newer Android build tools
[1.0.0+1]
- Initial release of
flutter_native_image_v2with support for Flutter 3.27.1. - Updated Android and iOS platform support for compatibility with newer Flutter versions.
[0.0.6+1]
- Changed constraints to support flutter 2.20.0
- Fix for missing transparency after crop (thanks to netgfx)
[0.0.6]
- Added null-safety support (thanks to dw2kim)
[0.0.5+3]
- v2 Embedding (thanks to adithyaxx)
[0.0.5+2]
- Reformatted flutter_native_image.dart
- Bump version to get the analysis going again
[0.0.5+1]
- Removed some sample code
- Added documentation for public API's
[0.0.5]
- Updated to AndroidX
- Changed constraints to only support flutter >=1.10.0
[0.0.1] - TODO: Add release date.
- Initial functionality
