Skip to content

Repository files navigation

image

Build Status

Overview

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

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

Performance Warning

Because this library is written entirely in Dart and is a not native executed library, its performance will not be as fast as a native library.

Supported Image Formats

Read/Write

  • PNG / Animated APNG
  • JPEG
  • Targa
  • GIF / Animated GIF
  • PVR(PVRTC)
  • ICO

Read Only

  • BMP
  • WebP / Animated WebP
  • TIFF
  • Photoshop PSD
  • OpenEXR

Write Only

  • CUR

Example

Load an image asynchronously and resize it as a thumbnail.

import'dart:io';
import'dart:isolate';
import'package:image/image.dart';
classDecodeParam {
finalFile file;
finalSendPort sendPort;
DecodeParam(this.file, this.sendPort);
}
voiddecodeIsolate(DecodeParam param) {
// Read an image from file (webp in this case).// decodeImage will identify the format of the image and use the appropriate// decoder.var image =decodeImage(param.file.readAsBytesSync())!;
// Resize the image to a 120x? thumbnail (maintaining the aspect ratio).var thumbnail =copyResize(image, width:120);
param.sendPort.send(thumbnail);
}
// Decode and process an image file in a separate thread (isolate) to avoid// stalling the main UI thread.voidmain() async {
var receivePort =ReceivePort();
awaitIsolate.spawn(
decodeIsolate, DecodeParam(File('test.webp'), receivePort.sendPort));
// Get the processed image from the isolate.var image =await receivePort.first asImage;
awaitFile('thumbnail.png').writeAsBytes(encodePng(image));
}

About

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

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages