A pure nodejs tga image parser and writer.
npm install tgaTGA
========
This is a pure Node.js module for parse or write tga image file.
Requirements
========
* Node.js v6
Installation
========
```
$ npm install tga --save
API
========
Example
========
`js
var fs = require('fs');
var TGA = require('tga');
var tga = new TGA(fs.readFileSync('./test.tga'));
console.log(tga.width, tga.height);
for (var i = 0; i < tga.pixels.length; i += 4) {
// the range of r, g, b and a is [0, 255]
console.log(tga.pixels[i], tga.pixels[i + 1], tga.pixels[i + 2], tga.pixels[i + 3]);
}
// save as another tga image
var buf = TGA.createTgaBuffer(tga.width, tga.height, tga.pixels);
fs.writeFileSync('./out.tga', buf);
// save the tga as png
var PNG = require('pngjs').PNG;
var png = new PNG({
width: tga.width,
height: tga.height
});
png.data = tga.pixels;
png.pack().pipe(fs.createWriteStream('./test.png'));
``