Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Dart library for decoding/encoding image formats, and image processing

image

Overview

A Dart library providing the ability to load, save and manipulate images in a variety of different file formats.

The library has no reliance on dart:io, so it can be used for both server and web applications.

Supported Image Formats:

Read/Write:

Read Only:

Write Only:

Documentation

API

Examples

Format Decoding Functions

Samples

Load an image, resize it, and save it as a png:

import 'dart:io';
import 'package:image/image.dart';
void main() {
  // Read an image from file (webp in this case).
  // decodeImage will identify the format of the image and use the appropriate
  // decoder.
  Image image = decodeImage(File('test.webp').readAsBytesSync());

  // Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
  Image thumbnail = copyResize(image, width: 120);

  // Save the thumbnail as a PNG.
  File('thumbnail.png')..writeAsBytesSync(encodePng(thumbnail));
}

Download Dart library for decoding/encoding image formats, and image processing source code on GitHub

https://github.com/brendan-duncan/image

Exit mobile version
Skip to toolbar