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).
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.
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.
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.
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.
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
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