https://github.com/prongbang/imgcompress
Compress JPEG Images in Flutter Using MozJpeg
https://github.com/prongbang/imgcompress
flutter-mozjpeg mozjpeg
Last synced: 3 months ago
JSON representation
Compress JPEG Images in Flutter Using MozJpeg
- Host: GitHub
- URL: https://github.com/prongbang/imgcompress
- Owner: prongbang
- License: mit
- Created: 2024-06-17T10:49:32.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-06-17T11:06:52.000Z (over 1 year ago)
- Last Synced: 2025-06-14T22:43:56.934Z (4 months ago)
- Topics: flutter-mozjpeg, mozjpeg
- Language: Dart
- Homepage: https://pub.dev/packages/imgcompress
- Size: 12.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# imgcompress
[](https://pub.dartlang.org/packages/imgcompress)
Compress JPEG Images in Flutter Using MozJpeg
## Getting Started
It is really easy to use! You should ensure that you add the `imgcompress` as a dependency in your flutter project.
```yaml
imgcompress: "^1.0.0"
```## Usage
#### New instance
```dart
final _imgCompress = FlutterImgCompress.instance;
```#### Compress Jpeg
```dart
final imgBytes = await rootBundle.load('assets/images/img.jpg');
final image = imgBytes.buffer.asUint8List();final imgDecode = img.decodeImage(image)!;
final width = imgDecode.width;
final height = imgDecode.height;
const quality = 90.0;var data = await _imgCompress.compress(ImgCompressOption(
image,
quality: quality,
width: width,
height: height,
format: ImgCompressFormat.jpeg,
));
```#### Example
