image_compression 1.0.3 icon indicating copy to clipboard operation
image_compression: ^1.0.3 copied to clipboard

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

Image Compression #

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

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}');
}
24
likes
120
pub points
90%
popularity

Publisher

verified publisher iconalan.my.id

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

Homepage

Documentation

API reference

License

Icon for licenses.unknown (LICENSE)

Dependencies

image, mime, path

More

Packages that depend on image_compression