image_compression
1.0.5, released 3 years ago by alan.my.id
A Dart extension for the image package to compress and resize images.
WASM-ready
What it does
Provides sync and async compression methods for images using an ImageFile configuration. Allows resizing and reducing image file sizes in pure Dart.
AI-written summary of version 1.0.5, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to compress and resize images in Dart
- You want a sync or queued async image compression solution
Skip it when
- You want to build for Flutter using native compression and WEBP format conversion (use image_compression_flutter instead)
Strengths
- Supports both synchronous and queued asynchronous compression
- Works across multiple platforms including Android, iOS, web, Windows, macOS, and Linux
Weaknesses
- Native compression and WEBP format conversion are not supported for Android and iOS in this package
- License is unknown
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
not documented
import 'dart:io';
import 'package:image_compression/image_compression.dart';
void main() {
final file = File('/path/to/image/file.jpg');
final input = ImageFile(
rawBytes: file.readAsBytesSync(),
filePath: file.path,
);
final output = compress(ImageFileConfiguration(input: input));
print('Input size = ${file.lengthSync()}');
print('Output size = ${output.sizeInBytes}');
}Alternatives
Packages that do the same job and could replace image_compression.
- flutter_image_compress
Provides native image compression optimized for Flutter applications on Android and iOS.
82Compare
Works with
Packages commonly used together with image_compression: ones it builds on, ones built on it, and its own family.
- mimeimage_compression depends on itUtilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.
- imageimage_compression depends on itPure Dart library to load, manipulate, encode, and decode various image formats.
- image_compression_flutterBuilt on image_compressionFlutter image compression and resizing for Mobile, Desktop, and Web.