Skip to content
pubscout

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
$ flutter pub add image_compression
Source repository

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.

Works with

Packages commonly used together with image_compression: ones it builds on, ones built on it, and its own family.