@anzerr/png.util
TypeScript icon, indicating that this package has built-in type declarations

3.3.13 • Public • Published

Intro

GitHub Actions status | publish

Simple PNG encoder/decoder for Node.js with no dependencies. fork from

Install

npm install --save git+https://github.com/anzerr/png.util.git
npm install --save @anzerr/png.util

Example

var fs = require('fs'),
    PNG = require('png.util').PNG;

fs.createReadStream('in.png')
    .pipe(new PNG({
        filterType: 4
    }))
    .on('parsed', function() {

        for (var y = 0; y < this.height; y++) {
            for (var x = 0; x < this.width; x++) {
                var idx = (this.width * y + x) << 2;

                // invert color
                this.data[idx] = 255 - this.data[idx];
                this.data[idx+1] = 255 - this.data[idx+1];
                this.data[idx+2] = 255 - this.data[idx+2];

                // and reduce opacity
                this.data[idx+3] = this.data[idx+3] >> 1;
            }
        }

        this.pack().pipe(fs.createWriteStream('out.png'));
    });

Package Sidebar

Install

npm i @anzerr/png.util

Weekly Downloads

0

Version

3.3.13

License

MIT

Unpacked Size

66.6 kB

Total Files

31

Last publish

Collaborators

  • anzerr
OSZAR »