Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js library for generating indexed PNGs?

Does anyone know of a node.js module for creating indexed PNGs?

I've looked through this list of node graphics modules, and some of them allow png creation, but none seem to allow you to specify an index/pallete scheme.

Just some extra info: I have a 2d Array representing pixels, each referring to an index of a 1d palette array. From this I would like to generate a valid indexed png file (1 channel, with 4 bits per channel).

like image 817
UpTheCreek Avatar asked Sep 04 '12 10:09

UpTheCreek


People also ask

What is indexing in node JS?

Indexes are data structures that support the efficient execution of queries in MongoDB. They contain copies of parts of the data in documents to make queries more efficient. Without indexes, MongoDB must scan every document in a collection to find the documents that match each query.

Is Node JS good for image processing?

With image processing, your application can resize and compress all the user-uploaded images, which can significantly improve your application performance and save your server disk space. Node. js has an ecosystem of libraries you can use to process images, such as sharp, jimp, and gm module.

How do I run a node JS index file?

To run this file, you should open up your terminal again and navigate to the directory in which you placed index. js. Once you successfully navigated yourself to the right spot, run your file using the node index. js command.

How do I read an image in node JS?

readFile() facilitates the simplest way to read a file in Node. js. For the arguments/parameters for this method, we must pass a file path, encoding, and a callback function that accepts the error and the file data as arguments. This callback function will be called with that data and the error.


1 Answers

Maybe png-stream could be worth a look. According to them:

You can also write data in the indexed color space by first quantizing it using the neuquant module.

Also, depending on what you're intending to do, another (cumbersome) possibility would be to use sng to convert PNG files to and from a textual representation.

Another option would be JS-PNG

like image 129
Haroldo_OK Avatar answered Sep 30 '22 19:09

Haroldo_OK