scrunch 1.0.2+1 copy "scrunch: ^1.0.2+1" to clipboard
scrunch: ^1.0.2+1 copied to clipboard

A package for compressing images and setting an upper limit on the max-size allowed for image files

Scrunch #

A package that allows you to compress image files in a separate isolate with the option of setting the desired size to trigger compression

Features #

  • Uses flutter_isolate to compress image files in a separate isolate.
  • Ability to set the image size from where compression should take place.

Getting started #

To use this package =>

Run this command:

flutter pub add scrunch

Or, add the following to your pubspec.yaml file:

dependencies:
    ...
    scrunch: LATEST_VERSION

Usage #

Import scrunch.dart

import 'package:scrunch/scrunch.dart';

Quick sample usage example

final Scrunch scrunch = Scrunch();

List<File> imageFilesToCompress = [image1, image2, image3];

Future<List<File>?> runCompression(List<File?> imageFiles) async {
  try {
    // The second argument passed into the function (5) is the size in megabytes that if the image
    // exceeds compression should take place
    final compressedFiles = await scrunch.compress(imageFiles, 5);
    return compressedFiles;
  } catch (e) {
    // Handle error
  } finally {
    scrunch.dispose();
  }
} 

final compressedImageFiles = await runCompression(imageFilesToCompress);

Additional information #

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

1
likes
140
pub points
19%
popularity

Publisher

unverified uploader

A package for compressing images and setting an upper limit on the max-size allowed for image files

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_image_compress, flutter_isolate, mime, path, path_provider

More

Packages that depend on scrunch