Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brendan-duncan/image
Dart Image Library for opening, manipulating, and saving various different image file formats.
https://github.com/brendan-duncan/image
dart dart-library dart-package dart-web dartlang flutter image image-processing jpeg png webp
Last synced: 24 days ago
JSON representation
Dart Image Library for opening, manipulating, and saving various different image file formats.
- Host: GitHub
- URL: https://github.com/brendan-duncan/image
- Owner: brendan-duncan
- License: mit
- Created: 2014-01-09T19:03:48.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T15:10:15.000Z (6 months ago)
- Last Synced: 2024-05-22T16:12:22.848Z (6 months ago)
- Topics: dart, dart-library, dart-package, dart-web, dartlang, flutter, image, image-processing, jpeg, png, webp
- Language: Dart
- Homepage:
- Size: 55.5 MB
- Stars: 1,132
- Watchers: 22
- Forks: 245
- Open Issues: 105
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-dart - image - Dart library for decoding/encoding image formats, and image processing. (Libraries / Image)
- awesome-game-engine-dev - image - Library for decoding / encoding image formats and image processing. (Libraries / Dart)
- awesome-dart - image - Provides server and web apps the ability to load, manipulate, and save images with various image file formats including PNG, JPEG, GIF, WebP, TIFF, TGA, PSD, PVR, and OpenEXR. (Image)
README
# Dart Image Library
[![Dart CI](https://github.com/brendan-duncan/image/actions/workflows/build.yaml/badge.svg?branch=4.0)](https://github.com/brendan-duncan/image/actions/workflows/build.yaml)
[![pub package](https://img.shields.io/pub/v/image.svg)](https://pub.dev/packages/image)## Overview
The Dart Image Library provides the ability to load, save, and
[manipulate](https://github.com/brendan-duncan/image/blob/main/doc/filters.md) images
in a variety of image file [formats](https://github.com/brendan-duncan/image/blob/main/doc/formats.md).The library can be used with both dart:io and dart:html, for command-line, Flutter, and
web applications.NOTE: 4.0 is a major revision from the previous version of the library.
## [Documentation](https://github.com/brendan-duncan/image/blob/main/doc/README.md)
### [Supported Image Formats](https://github.com/brendan-duncan/image/blob/main/doc/formats.md)
**Read/Write**
- JPG
- PNG / Animated APNG
- GIF / Animated GIF
- BMP
- TIFF
- TGA
- PVR
- ICO**Read Only**
- WebP / Animated WebP
- PSD
- EXR
- PNM (PBM, PGM, PPM)**Write Only**
- CUR
## Examples
Create an image, set pixel values, save it to a PNG.
```dart
import 'dart:io';
import 'package:image/image.dart' as img;
void main() async {
// Create a 256x256 8-bit (default) rgb (default) image.
final image = img.Image(width: 256, height: 256);
// Iterate over its pixels
for (var pixel in image) {
// Set the pixels red value to its x position value, creating a gradient.
pixel..r = pixel.x
// Set the pixels green value to its y position value.
..g = pixel.y;
}
// Encode the resulting image to the PNG image format.
final png = img.encodePng(image);
// Write the PNG formatted data to a file.
await File('image.png').writeAsBytes(png);
}
```To asynchronously load an image file, resize it, and save it as a thumbnail:
```dart
import 'package:image/image.dart' as img;void main(List args) async {
final path = args.isNotEmpty ? args[0] : 'test.png';
final cmd = img.Command()
// Decode the image file at the given path
..decodeImageFile(path)
// Resize the image to a width of 64 pixels and a height that maintains the aspect ratio of the original.
..copyResize(width: 64)
// Write the image to a PNG file (determined by the suffix of the file path).
..writeToFile('thumbnail.png');
// On platforms that support Isolates, execute the image commands asynchronously on an isolate thread.
// Otherwise, the commands will be executed synchronously.
await cmd.executeThread();
}
```