jsng is a JS encoder/decoder for the ever-popular and inefficient JSON-G format.
JSON-G (JSON-Graphics) is an extremely inefficient way to store raster image data, with transparency and layered support!
Using jsng allows you to combine the inefficiency and extensive features of JSON-G with the flexibility and ease-of-use of JavaScript, allowing you to seamlessly create and use JSON-G files wherever you are!
jsng is also the most efficient JSON-G library on the internet (as of 2017 February 15), outperforming any other encoder/decoder both in terms of speed and filesize.
- Support for an infinite number of layers
- Support for optional transparency
- Comment support for each individual pixel
- Incredibly large filesizes (approximately 400x bigger than equivalent PNGs)
- Human-readable formatting
npm install abalabahaha/jsng
The API is relatively simple, and has just two functions.
file
- a string pointing to a JPG or PNG filecallback(err, jsng)
- a callback function with the following parameterserr
- an Error object, null if no error was encounteredjsng
- an Object containing the JSON-G data for the image
file
- a string pointing to a JSNG filecallback(err, jsng)
- a callback function with the following parameterserr
- an Error object, null if no error was encounteredbuffer
- a Buffer containing the JPG or PNG data for the imagemimeType
- a String containing the MIME type of the image
See the examples
folder for example decoder and encoder scripts.
- Roadcrosser/JSON-G (Python script)
- Gorialis/JSON-G (Python module)
- node-json-g (NodeJS module)
- PHP JSON-G (PHP)
- json-g.rs (Rust crate)
- See the official JSON-G library index for more