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. Here you can compress photos and images online and reduce their file size of up to 90% the original size, without losing the visual quality. Just select the PNG, JPG, JPEG or GIF file (max 50MB) and wait.
Compresses image as native plugin (Obj-C/Kotlin)
This online image optimizer uses a smart combination of the best optimization and lossy compression algorithms to shrink JPEG and PNG images to the minimum possible size while keeping the required level of quality. Upload up to 20 images. Wait for the compression to. Compress JPEG Images Online. Compress JPEG JPG images online for free with this JPEG compression and optimization tool. Reduce JPEG images file size, make JPEG images smaller online. This service allows you to compress JPEG images online, directly from your web browser and without the need to install third-party software.
This library can works on Android and iOS.
- flutter_image_compress
- About common params
- format
- HEIF(Heic)
- format
- Result
- Troubleshooting or common error
- LICENSE
- About common params
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 #
Use as:
There are several ways to use the library api.
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:If your image width is smaller than minWidth or height samller 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).
And support iOS, but However, no system implementation, using third-party libraries used, 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 is no guarantee of implementation time.
HEIF(Heic)
Heif for iOS
Only support iOS 11+.
Heif for Android
Use https://developer.android.com/reference/androidx/heifwriter/HeifWriter.html to implemation.
Only support API 28+.
And may require hardware encoder support, does not guarantee that all devices above API28 are available
inSampleSize #
The param is only support android.
For a description of this parameter, see the Android official website.
keepExif #
If this parameter is true, EXIF information is saved in the compressed result.
Attention should be paid to the following points:
- Default value is false.
- Even if set to true, the direction attribute is not included.
- 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<int>
and Uint8List
#
You may need to convert
List<int>
to Uint8List
to display images.To use
Uint8List
, you need import package to your code like this:Usage in
Image
Widget:Write to file usage:
Runtime Error #
Because of some support issues, all APIs will be compatible with format and system compatibility, and an exception (UnsupportError) 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:
Android #
You may need to update Kotlin to version
1.3.72
or higher.iOS #
Jpg Compress 2 2 0 3
No problems currently found.
Troubleshooting or common error #
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 plugin to access some application folders, and use a permission plugin to request permission to access SD cards on Android/iOS.
Android build error #
See flutter/flutter/issues#21473
You need to upgrade your Kotlin version to
1.2.71+
(recommended 1.3.72).If Flutter supports more platforms (Windows, Mac, Linux, etc) in the future and you use this library, propose an issue or PR!
About EXIF information #
Cardhop 1 2 2 x 4. Using this library, EXIF information will be removed by default.
EXIF information can be retained by setting keepExif to true, but not
direction
information.LICENSE #
Jpg Compress 2 2 07
The code under MIT style.
PNG/JPEG encoder #
Each using system API.
Webp encoder #
Use SDWebImageWebPCoder to encode the UIImage in iOS. (Under MIT)
Android code use the Android system api.
HEIF encoder #
Use iOS system api in iOS.
Small Jpg Compress
Text editor. Use HeifWriter(androidx component by Google) to encode in androidP or higher.
About Exif handle code #
The iOS code was copied from dvkch/SYPictureMetadata, LICENSE
The android code was copied from flutter/plugin/image_picker and edit some. (BSD 3 style)
![Jpg compress 2 2 0 3 Jpg compress 2 2 0 3](https://tumblbug-pci.imgix.net/d3257920215d297de816e473e280cbe3f3e8ec3f/aaa2a0f7c61ad7828423d830930c7e1191467015/85fe83020f36572588d8bec5da882b978a4decf3/87c04a40-1404-473c-9bdc-b3e7095a07aa.jpg?ixlib=rb-1.1.0&w=620&h=465&auto=format%2Ccompress&lossless=true&fit=crop&s=7f027a162346c8fcd0c73766f54a33e1)
Select a picture on your computer or phone, specify the desired size in kilobytes, megabytes or percentages and then click OK button at the bottom of this page. Other settings are already installed by default. Still it is possible to compress JPG file by standard method by specifying level of quality.
Mac dvdripper pro 7 1 2 download free. A large picture of about 20 megapixels (5484x3646) and 5-10 megabytes in most cases can not be compressed to 200-500 KB, but if you specify 'size reducing in megapixels' up to 3 or 5, then it will be real, and without the appearance of pixelation (squares) and without jpeg artifacts due to heavy compression.
The original image is not changed. You will be given other processed image in JPG format.