downsize 1.0.0 copy "downsize: ^1.0.0" to clipboard
downsize: ^1.0.0 copied to clipboard

Pure dart image compression across multiple formats, including JPG, PNG, GIF, BMP, TIFF, TGA, PVR, and ICO.

Downsize #

Downsize is a pure Dart package designed for image compression across multiple formats, including JPG, PNG, GIF, BMP, TIFF, TGA, PVR, and ICO. It efficiently reduces file sizes while maintaining quality and dynamically resizes large images, making it ideal for optimizing images in web or mobile applications.

This package is built on top of the image Dart package, providing additional functionality for compression and resizing with an easy-to-use API.

Features #

  • Supports compression for a wide range of image formats: JPG, PNG, GIF, BMP, TIFF, TGA, PVR, ICO, and more.
  • Automatically resizes images based on predefined size thresholds.
  • Customizable compression quality and target file size.
  • Specific compression techniques for different formats, such as reducing color depth for PNG files.
  • Fully integrates with Dart projects without requiring external dependencies beyond this package.

Getting started #

Prerequisites #

Installation #

  1. Add downsize to your project’s pubspec.yaml file:
dependencies:
  downsize:
  1. Install the dependencies:
dart pub get

Usage #

Here’s a simple example to compress an image using Downsize:

import 'dart:io';
import 'package:downsize/downsize.dart';

void main() async {
  File imageFile = File('path/to/your/image.jpg'); // Replace with any supported format
  Uint8List imageData = await imageFile.readAsBytes();

  // Uint8List? compressedData = await Downsizer.downsize(data: imageData); // Compress with default options.

  Uint8List? compressedData = await Downsizer.downsize(data: imageData, maxSize: 500, minQuality: 60); // Compress to 500 KB with 60% as minimum quality
  
  if (compressedData != null) {
    await File('path/to/save/compressed_image.jpg').writeAsBytes(compressedData);
    print('Image compressed and saved.');
  }
}

The same function works with all supported image formats. Simply provide the image data and specify the desired file size or compression quality.

Additional information #

For more information, visit the repository. You can report issues or contribute by opening a pull request or an issue on GitHub.

Contributing #

Contributions are welcome! Please ensure your code follows best practices and the included lints. To contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request.

Thank you for using Downsize!

3
likes
0
points
21
downloads

Publisher

verified publisheryaseen.dev

Weekly Downloads

Pure dart image compression across multiple formats, including JPG, PNG, GIF, BMP, TIFF, TGA, PVR, and ICO.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

image

More

Packages that depend on downsize