Search packages, repositories and app categories

GitHub repositoryalann-maulana/image_compression

image_compression

A Dart Extension for image package to compress and resize the images.

image_compression project cover
Stars
11
Forks
11
Last push (UTC)
Feb 15, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Image Compression

A Dart Extension for image package to compress and resize the images.

If you want to build for Flutter, use image_compression_flutter package. It support native compression and WEBP format conversion (Android & iOS only).

Sync Compression

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}');
}

Async Compression

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 = await compressInQueue(ImageFileConfiguration(input: input));

  print('Input size = ${file.lengthSync()}');
  print('Output size = ${output.sizeInBytes}');
}
Alann Maulana GitHub avatar
GitHub author

Alann Maulana ↗

Tenaga Kanggo Indonesia, PTTangerang
LanguagesDart

Dependencies used

Dependency list 5 items

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗