How do you load the Image Server into the dart?

I saw answers to using ImageElement to load an image. This only works on the browser side, and I would like to do some processing on the server.

Is there a way to load and read RGBA values ​​from PNG on the server side? If not, are there server-side image processing libraries planned?

Is there a way to run Dartium headless so that I can use the api canvas to do what I want?

+4
source share
2 answers

There is a dart library that can read and write PNG image server, http://pub.dartlang.org/packages/image

The library can read and write PNG and JPG images and provides several image management commands.

For example, to read PNG, resize it and save 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)); } 
+5
source

There is currently no library.

I used ImageMagick . You can use Process.run() to start it. Here is an example:

 Process.run('/usr/local/bin/convert', ['file', '-resize', '100x100']); 
+2
source

Source: https://habr.com/ru/post/1488119/


All Articles