Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/ppm
A parser/exporter for the greatest image format ever created.
https://github.com/mikolalysenko/ppm
Last synced: about 2 months ago
JSON representation
A parser/exporter for the greatest image format ever created.
- Host: GitHub
- URL: https://github.com/mikolalysenko/ppm
- Owner: mikolalysenko
- Created: 2013-02-13T16:50:16.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-04-18T22:23:07.000Z (over 8 years ago)
- Last Synced: 2024-10-20T14:28:17.098Z (2 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 12
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ppm
===
This code implements a streaming parser/serializer for ascii [PPM formatted](http://netpbm.sourceforge.net/doc/ppm.html) images in JavaScript. The PPM file format is very simple and human readable, so it can be useful when debugging graphics applications. The downside though is that PPM is not a very efficient format, and so it is not really suitable for long term archival or transmission of images. For those applications, you should use a standard network image format like PNG or JPEG, depending on your requirements.Usage/Installation
==================
To install, first you do:npm install ppm
And here is how you can use it to write/read back an image:
var ppm = require("ppm");
var image = [
[[255, 0, 0], [255, 0, 0], [255, 0, 0]],
[[0, 255, 0], [0, 255, 0], [0, 255, 0]],
[[0, 0, 255], [0, 0, 255], [0, 0, 255]]
];ppm.parse(ppm.serialize(image), function(err, img) {
console.log(err, img);
});The API is streaming, and should be compatible with all the stand node.js features from fs/net/etc..
`ppm.parse(stream, cb(err, result))`
------------------------------------
Parses an ASCII ppm file from `stream`. When finished, calls `cb` with the
error and result of parsing the file. `result` will be an array of arrays of the
form```js
[[r, g, b], [r, g, b], ...]
````ppm.serialize(image)`
----------------------
Converts an array of arrays (RGB data; see above fo rformat) representing an
image into an ASCII ppm stream.Credits
=======
(c) 2013 Mikola Lysenko. BSD