1.0.0 • Published 5 years ago

png-js v1.0.0

Weekly downloads
535,539
License
-
Repository
github
Last release
5 years ago

png.js

A PNG decoder in JS for the canvas element or Node.js.

Browser Usage

Simply include png.js and zlib.js on your HTML page, create a canvas element, and call PNG.load to load an image.

<canvas></canvas>
<script src="zlib.js"></script>
<script src="png.js"></script>
<script>
    var canvas = document.getElementsByTagName('canvas')[0];
    PNG.load('some.png', canvas);
</script>

The source code for the browser version resides in png.js and also supports loading and displaying animated PNGs.

Node.js Usage

Install the module using npm

sudo npm install png-js

Require the module and decode a PNG

var PNG = require('png-js');
PNG.decode('some.png', function(pixels) {
    // pixels is a 1d array (in rgba order) of decoded pixel data
});

You can also call PNG.load if you want to load the PNG (but not decode the pixels) synchronously. If you already have the PNG data in a buffer, simply use new PNG(buffer). In both of these cases, you need to call png.decode yourself which passes your callback the decoded pixels as a buffer. If you already have a buffer you want the pixels copied to, call copyToImageData with your buffer and the decoded pixels as returned from decodePixels.

@moonlasher/saffron@screenplayer/pdfkit@infinitebrahmanuniverse/nolb-pn@everything-registry/sub-chunk-2451wimagexcodsplatcur-editor@darkguardace/pdfkit@postermywall/pdfkitjoadr-pdfkitkik-node-api@habitat-game/core@fc3/corespritesheetjssunne-pdfkittracker-clitransmogrifierunitive-pdfkit@artdotstyle/filepix@charitips/pdfkit@adamhudsonnall/pdf-signer@foliojs-fork/pdfkit@feamzy/pdfkit@evaneos/pdfkit@ginixsan/pdf-signer@goodboydigital/bulldog@mapcatch/pdfkit@jvodicka/pdfkit@jimle_uk/pdfkit@joostlubach/pdfkit@kittl/pdfkit@image-twins/core@react-pdf/core@react-pdf-precompiled/core@saiarlen/pdf-signer-latest@openartmarket/pdfkit@pinheirorb/pdf-icp-brasil@ph-gomes/pdf-signer@nrkn/pdfkit@pirles/pdfkit@nxmix/pdfkit@spiandorelo/pdf-signer-brazil@robotikzz/pdfkitmindmup-pdfkitpdfapdfa_3bpdiffypdf-digital-signerpdfkit-ignore-invalid-fontspdfkit-link-patchpdfkit-litepdfkit-memorypdfkit-modifiedpdfkit-nextpdfkit-nkpdfkit-outlinepdfkit-plus-contentspdfkit-revmuunpdfkit-richtextpdfkitpdfkit-betapdfkit-cachekerningpdfkit-cjkpdfkit-cmykpdfkit-espdf-signerpdf-signer-agetecpdf-signer-brazilrptd-img-loadersaucisse-clineural-now-utilsnode-serverless-pdfkitpgte-pdfkitphashbufferpicture-tubepicture-tuberpng-file-streampng-to-jpegpdfmake-pdfkitpdfkit2pdfkitf1pdfkittenpptx-image-templaterpure-color-thief-nodeqripreact-pdf-coreshotssigner-cailunsocial-gif-kodyfiregifectgrunt-cordovagrunt-image-dataimghash-turbohyper-record-sessioniconatorgrunt-pngcheckgrfnvizlive-markdown@suvelocity/tester@t-project/pdfkit
1.0.0

5 years ago

0.1.1

12 years ago

0.1.0

13 years ago