{"_id":"node-png","_rev":"359129","name":"node-png","description":"Simple PNG encoder/decoder","dist-tags":{"latest":"0.4.3"},"maintainers":[{"name":"brighthas","email":"brighthas@gmail.com"}],"time":{"modified":"2021-07-13T08:44:37.000Z","created":"2013-10-21T12:54:57.172Z","0.4.3":"2014-06-20T00:17:56.895Z","0.4.2":"2013-10-21T13:09:26.936Z","0.4.1":"2013-10-21T12:54:57.172Z"},"users":{"andrew.medvedev":true,"noopkat":true},"author":{"name":"Kuba Niegowski"},"repository":{"type":"git","url":"git://github.com/brighthas/node-pngjs.git"},"versions":{"0.4.3":{"name":"node-png","version":"0.4.3","description":"Simple PNG encoder/decoder","author":{"name":"Kuba Niegowski"},"contributors":[],"homepage":"https://github.com/niegowski/node-pngjs/","keywords":["png"],"engines":{"node":"0.8.x"},"main":"./lib/png.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/brighthas/node-pngjs.git"},"license":"MIT","bugs":{"url":"https://github.com/brighthas/node-pngjs/issues"},"gitHead":"1415f9fe1a8780b788d05cf73403574ef1ace813","_id":"node-png@0.4.3","_shasum":"450223796b82d3cca0ffe4a5d5c7fa97485974e7","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"brighthas","email":"brighthas@gmail.com"},"maintainers":[{"name":"brighthas","email":"brighthas@gmail.com"}],"dist":{"shasum":"450223796b82d3cca0ffe4a5d5c7fa97485974e7","size":29410,"noattachment":false,"key":"/node-png/-/node-png-0.4.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/node-png/download/node-png-0.4.3.tgz"},"publish_time":1403223476895,"_cnpm_publish_time":1403223476895,"_hasShrinkwrap":false},"0.4.2":{"name":"node-png","version":"0.4.2","description":"Simple PNG encoder/decoder","author":{"name":"Kuba Niegowski"},"contributors":[],"homepage":"https://github.com/niegowski/node-pngjs/","keywords":["png"],"engines":{"node":"0.8.x"},"main":"./lib/png.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/brighthas/node-pngjs.git"},"license":"MIT","bugs":{"url":"https://github.com/brighthas/node-pngjs/issues"},"readmeFilename":"README.md","_id":"node-png@0.4.2","dist":{"shasum":"eebe50ca1b520b6fa24b6ab205d0e9f8ddf05747","size":29387,"noattachment":false,"key":"/node-png/-/node-png-0.4.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/node-png/download/node-png-0.4.2.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"brighthas","email":"brighthas@gmail.com"},"maintainers":[{"name":"brighthas","email":"brighthas@gmail.com"}],"publish_time":1382360966936,"_cnpm_publish_time":1382360966936,"_hasShrinkwrap":false},"0.4.1":{"name":"node-png","version":"0.4.1","description":"Simple PNG encoder/decoder","author":{"name":"Kuba Niegowski"},"contributors":[],"homepage":"https://github.com/niegowski/node-pngjs/","keywords":["png"],"engines":{"node":"0.8.x"},"main":"./lib/png.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/brighthas/node-pngjs.git"},"license":"MIT","bugs":{"url":"https://github.com/brighthas/node-pngjs/issues"},"readmeFilename":"README.md","_id":"node-png@0.4.1","dist":{"shasum":"113894505cacd9b68589c77963a8d6932c7e6251","size":29385,"noattachment":false,"key":"/node-png/-/node-png-0.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/node-png/download/node-png-0.4.1.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"brighthas","email":"brighthas@gmail.com"},"maintainers":[{"name":"brighthas","email":"brighthas@gmail.com"}],"publish_time":1382360097172,"_cnpm_publish_time":1382360097172,"_hasShrinkwrap":false}},"readme":"About\n========\nSimple PNG encoder/decoder for Node.js with no native dependencies.\n\nInstallation\n===============\n```\n$ npm install node-png \n```\n\nExample\n==========\n```js\nvar fs = require('fs'),\n    PNG = require('pngjs').PNG;\n\nfs.createReadStream('in.png')\n    .pipe(new PNG({\n        filterType: 4\n    }))\n    .on('parsed', function() {\n\n        for (var y = 0; y < this.height; y++) {\n            for (var x = 0; x < this.width; x++) {\n                var idx = (this.width * y + x) << 2;\n\n                // invert color\n                this.data[idx] = 255 - this.data[idx];\n                this.data[idx+1] = 255 - this.data[idx+1];\n                this.data[idx+2] = 255 - this.data[idx+2];\n\n                // and reduce opacity\n                this.data[idx+3] = this.data[idx+3] >> 1;\n            }\n        }\n\n        this.pack().pipe(fs.createWriteStream('out.png'));\n    });\n```\nFor more examples see `examples` folder.\n\nDocumentation\n================\n\nAs input any color type is accepted (grayscale, rgb, palette, grayscale with alpha, rgb with alpha) but 8 bit per sample (channel) is the only supported bit depth. Interlaced mode is not supported.\n\n### Supported ancillary chunks\n- `gAMA` - gamma,\n- `tRNS` - transparency (but only for paletted image)\n\n\n## Class: PNG\n`PNG` is readable and writable `Stream`.\n\n\n### Options\n- `width` - use this with `height` if you want to create png from scratch\n- `height` - as above\n- `checkCRC` - whether parser should be strict about checksums in source stream (default: `true`)\n- `deflateChunkSize` - chunk size used for deflating data chunks, this should be power of 2 and must not be less than 256 and more than 32*1024 (default: 32 kB)\n- `deflateLevel` - compression level for delate (default: 9)\n- `deflateStrategy` - compression strategy for delate (default: 3)\n- `filterType` - png filtering method for scanlines (default: -1 => auto, accepts array of numbers 0-4)\n\n\n### Event \"metadata\"\n`function(metadata) { }`\nImage's header has been parsed, metadata contains this information:\n- `width` image size in pixels\n- `height` image size in pixels\n- `palette` image is paletted\n- `color` image is not grayscale\n- `alpha` image contains alpha channel\n\n\n### Event: \"parsed\"\n`function(data) { }`\nInput image has been completly parsed, `data` is complete and ready for modification.\n\n\n### Event: \"error\"\n`function(error) { }`\n\n\n### png.parse(data, [callback])\nParses PNG file data. Alternatively you can stream data to instance of PNG.\n\nOptional `callback` is once called on `error` or `parsed`. The callback gets\ntwo arguments `(err, data)`.\n\nReturns `this` for method chaining.\n\n\n### png.pack()\nStarts converting data to PNG file Stream.\n\nReturns `this` for method chaining.\n\n\n### png.bitblt(dst, sx, sy, w, h, dx, dy)\nHelper for image manipulation, copies rectangle of pixels from current image (`sx`, `sy`, `w`, `h`) to `dst` image (at `dx`, `dy`).\n\nReturns `this` for method chaining.\n\n\n### Property: width\nWidth of image in pixels\n\n\n### Property: height\nHeight of image in pixels\n\n\n### Property: data\nBuffer of image pixel data. Every pixel consists 4 bytes: R, G, B, A (opacity).\n\n\n### Property: gamma\nGamma of image (0 if not specified)\n\nChangelog\n============\n\n### 0.4.0 - Jun 05 2013\n  - fixed reading of destroyed input stream\n\n### 0.4.0-alpha - 29 Nov 2012\n  - added zlib deflateStrategy option, default to Z_RLE (by pdpotter)\n  - added possibility to use multiple filters (by pdpotter, modified by niegowski)\n\n### 0.3.0-alpha - 23 Aug 2012\n  - Processing data as Streams, not complete Buffers of data\n\n### 0.2.0-alpha - 21 Aug 2012\n  - Input added palette, grayscale, no alpha support\n  - Better scanline filter selection\n\n### 0.1.0-alpha - 19 Aug 2012\n  - First version\n\nLicense\n=========\n\n(The MIT License)\n\nCopyright (c) 2012 Kuba Niegowski\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","_attachments":{},"homepage":"https://github.com/niegowski/node-pngjs/","bugs":{"url":"https://github.com/brighthas/node-pngjs/issues"},"license":"MIT"}