I've seen the answers for using an ImageElement to load an image. This only works on the browser side and I wanted to do some processing on the server.
Is there any way to load and read RGBA values from a PNG in server side dart? If not are there any server side image processing libraries planned?
Is there anyway to run Dartium "headless" so I can use the canvas api to do what I want?
There is a dart library that can read and write PNG images server side, http://pub.dartlang.org/packages/image
The library can read and write PNG and JPG images, and provides a number of image manipulation commands.
For example, to read a PNG, resize it, and save it to disk using this library:
import 'dart:io' as Io;
import 'package:image/image.dart';
void main() {
// Read a PNG image from file.
Image image = readPng(new Io.File('foo.png').readAsBytesSync());
// Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
Image thumbnail = copyResize(image, 120);
// Save the thumbnail to disk as a PNG.
new Io.File('foo-thumbnail.png').writeAsBytesSync(writePng(thumbnail));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With