{"_id":"png","_rev":"37-35c9bada7e903e00d0eec87f4de7186e","name":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","dist-tags":{"latest":"3.0.3"},"versions":{"1.0.0":{"name":"png","version":"1.0.0","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to a PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","web":"http://www.catonmat.net","twitter":"pkrumins"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples"},"engines":{"node":">=0.1.93"},"scripts":{"install":"node-waf configure build"},"_id":"png@1.0.0","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/png/-/png-1.0.0.tgz","shasum":"66023199b21a5a3bbba53837529b798b2c9ed01d","integrity":"sha512-dfRbgvRkm2/9xB9D3Gso7earlHKB8MCf1Mc6npXp36yKpik9UXUBct+TlTY09T5EkrMnf2q9FbSrZY5O2nJCKQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEEWF+ZaYB5aY5/dWzijOg23iwdgym1opSqbgc5QfABBAiEAwGDNk6Udnk8bNAkLA6Tpr3jhWWEAvrOY/BBNQms2NhE="}]}},"1.0.1":{"name":"png","version":"1.0.1","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to a PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","web":"http://www.catonmat.net","twitter":"pkrumins"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples"},"engines":{"node":">=0.1.93"},"scripts":{"install":"node-waf configure build"},"_id":"png@1.0.1","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/png/-/png-1.0.1.tgz","shasum":"e5c6ef795c640fa4b77e61675fb93f45abf8dfe6","integrity":"sha512-C67iiSX2QOQBbBMJkqvpBYv0i0GBB6DjByukAasKFKdXWOVsDKqqGrD59rgiw7GLfg065JovF1Hw+TyYZZNnMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICI+60d3O5Y1uJhbXVm0BVsdSWxjd/LAxLonWewppSSAAiAYjl+/32TKdnQpU/YPPfl9FjKR0FucYLUnHpHHqzpgGw=="}]}},"1.0.2":{"name":"png","version":"1.0.2","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","web":"http://www.catonmat.net","twitter":"pkrumins"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples"},"engines":{"node":">=0.1.93"},"scripts":{"install":"node-waf configure build"},"_id":"png@1.0.2","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/png/-/png-1.0.2.tgz","shasum":"5e0f62cd867cc3e4a9a357560a0ca319c27afacc","integrity":"sha512-eCQ9Qxe+5TUZDKq4TVBuyARqGNKR2+1Cp5wenWnqtjfHhz+iCNdmOihBiSYBUjAwpTWOnpA0brRT3J4MbgjMyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA7VM8IK3TzrfeUNW6k4fYz6DNUGN3l3Y4HCcCtPoa44AiAKdOKQPC/+0VCxob1fqbRfHC7elDl8krll6qBmN1EK9A=="}]}},"1.0.3":{"name":"png","version":"1.0.3","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","web":"http://www.catonmat.net","twitter":"pkrumins"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.1.93"},"scripts":{"install":"node-waf configure build"},"_id":"png@1.0.3","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/png/-/png-1.0.3.tgz","shasum":"3fe4b6dc19391c2caab851fd58c0cdc813917f4d","integrity":"sha512-9iNH82XjNULbnIKtos6z8vulxMBQcR4RnqlDgL56ctEkAh0jxcdfrcM/jcyEWfxePFEp/J+0LnovLaKx45BUkw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2NZgeFUMyvW/JzqR/9ZjEq3ZPel5aGdnPMo2XPkcI0AiAwevpZvnNj/XjgqkD43PHZLyuNHwiSCwNO2kUNkg4a8A=="}]}},"2.0.0":{"name":"png","version":"2.0.0","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","web":"http://www.catonmat.net","twitter":"pkrumins"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.3.0"},"scripts":{"install":"node-waf configure build"},"_id":"png@2.0.0","_nodeSupported":false,"_npmVersion":"0.2.5-1","_nodeVersion":"v0.2.4","dist":{"tarball":"https://registry.npmjs.org/png/-/png-2.0.0.tgz","shasum":"1b3cc4723026bb3745426b39bb4c5eef2ff3ec23","integrity":"sha512-Zs5yZsOmQ1M+AS1uXTg2Ih5+WpzbELMFgs2FANQwKTz5k5FH64P6maqJH0L57Zvt6PQt+gE9eCXOyTmd7vZ3NA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBOtOJ+iIKHEaCpOKG38HCPKKj0LCNqSphZ06tS51QsjAiBxxLSJKZYz0GtSQaE04f0a4MamkEVeP4yuYEYBk1rGDQ=="}]}},"2.0.1":{"name":"png","version":"2.0.1","main":"png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.3.0 <0.5"},"scripts":{"install":"node-waf configure build"},"_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"_id":"png@2.0.1","dependencies":{},"devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"2e7148df6051843aa496e8ba120a364d06c3c2c1","tarball":"https://registry.npmjs.org/png/-/png-2.0.1.tgz","integrity":"sha512-SnkOLtE6BVvDuTACpxfM/dc7VIq+LVn6GUGogmDjqYsVbjvyiNrMwe/iQt5a9qSHjhHiANHKq0cvMRJrbLGSLw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGuuY7hKL4u9tB7BjZ7qQQMel2tEbj05/JdUz3CzcfD/AiEA4lDvstuHAC6SnH2dmNTJoKLjWAzB6Neh16t/QETniQU="}]}},"2.1.0":{"name":"png","version":"2.1.0","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture"],"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}],"licenses":[{"type":"MIT"}],"repositories":[{"type":"git","url":"http://github.com/pkrumins/node-png.git"}],"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"scripts":{"install":"node-waf configure build"},"_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"_id":"png@2.1.0","dependencies":{},"devDependencies":{},"_engineSupported":false,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"88f4b7cc8bf33aaf7022bfcd223deada5a0f60df","tarball":"https://registry.npmjs.org/png/-/png-2.1.0.tgz","integrity":"sha512-2jrSwR6811TwXg42prZbEwz/Ph/9+6Hq9lb/PAVEZ2pQLcrTOJ5Pk51HggHvL6VwUghG6eWkU3XGpNCUyPdgZw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBvCi/ETqSSzhmZkFmCkPn2TXn5yh6lFJ9puLMos3szQIhAP7gC9OvdrDmlF8aA/D0znSSSLUO1y13ZdWMQSzDO0ae"}]}},"2.1.1":{"name":"png","version":"2.1.1","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture","encode"],"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"license":{"type":"MIT"},"repository":{"type":"git","url":"git://github.com/pkrumins/node-png.git"},"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"scripts":{"install":"node-waf configure build"},"_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"_id":"png@2.1.1","dependencies":{},"devDependencies":{},"_engineSupported":false,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"777f29570208d24695cc37e4b63772b0b2a85948","tarball":"https://registry.npmjs.org/png/-/png-2.1.1.tgz","integrity":"sha512-WFzE+emW475rdvpEiEiI434as4ywns1eFJNCZLnSFSbVxxV8ychIHJgBsA8ajJNpEb0um4Mpz8H0NZdswoyjNA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF4ko+s9PyTkWIeYXnaCexIpDKDburyLSepUwUPRzjdTAiEA+fz8369I1rrqoRMTpiF9wqeGI1rhnkjiOcdsZ9pvbiQ="}]},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}]},"3.0.0":{"name":"png","version":"3.0.0","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture","encode"],"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"license":{"type":"MIT"},"repository":{"type":"git","url":"git://github.com/pkrumins/node-png.git"},"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"_id":"png@3.0.0","scripts":{"install":"node-gyp rebuild"},"dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.12","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"ab4b935890422b59c12731e269ea02ca97abad44","tarball":"https://registry.npmjs.org/png/-/png-3.0.0.tgz","integrity":"sha512-7FmjV+HImIs/B50flyEoFROz2P93oWDtHPByQW8Ejlo/SYdt82zahMpy3MywLLGGGyhG9bXcl11GXlGfOEiUfw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB5H36nqewgbEK/aB/CRX9DT5YXoHGp6e8wNjs8JgI5WAiEA45Yo6po4DmfYyewNNQ6YoJksV08fJQeRSGStTpHQEGM="}]},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}]},"3.0.1":{"name":"png","version":"3.0.1","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture","encode"],"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"license":{"type":"MIT"},"repository":{"type":"git","url":"http://github.com/pkrumins/node-png.git"},"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"png@3.0.1","dist":{"shasum":"475270d9c8806c159882fe766160b58ac6a5969f","tarball":"https://registry.npmjs.org/png/-/png-3.0.1.tgz","integrity":"sha512-9ePPWdOqQDBuG+Cz6N8mojhGnl5vjWEi5fFoWl62nImAIfFSHGQw4cL+BzK5WMu1u5giCyn2pU0aByUnxPuCDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF8FoJXZbgEtTF36X5bq5uH83oGiDwCp9Fq968eCl2y9AiEAuy48zd82G5P7DxUr9MzY/7BoZiHm2vOuRHwR12wgZN0="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}]},"3.0.2":{"name":"png","version":"3.0.2","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture","encode"],"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"license":{"type":"MIT"},"repository":{"type":"git","url":"http://github.com/pkrumins/node-png.git"},"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"png@3.0.2","dist":{"shasum":"cbf539c58d7aeb829f14f93b2f6713403fe34e94","tarball":"https://registry.npmjs.org/png/-/png-3.0.2.tgz","integrity":"sha512-+DKvX5XX3MKCxoV3vMEk/oFu/+6utz1WUuQm6RrqS6W7VKxbFKsdGmJ9g7UAD3kqLIUmQN1EZdMRNTWDjxIACw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvY+OJF2owSnG7EH/LZo6lvxGyWzDbe17FNEum1mtP5QIgbi05Cf8Su40vaTAkJesKy+E/uubvK6w6hrAI/SLd6Yc="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}]},"3.0.3":{"name":"png","version":"3.0.3","main":"./build/Release/png","description":"A C++ module for node-js that converts an RGB and RGBA buffers to PNG images (in memory).","keywords":["png","rgb","rgba","image","picture","encode"],"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"license":{"type":"MIT"},"repository":{"type":"git","url":"http://github.com/pkrumins/node-png.git"},"directories":{"examples":"examples","src":"src"},"engines":{"node":">=0.6.0"},"scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"png@3.0.3","dist":{"shasum":"15024958b2135af55349f60763a066b24ed9e283","tarball":"https://registry.npmjs.org/png/-/png-3.0.3.tgz","integrity":"sha512-53npnXKg9Pecjt94DgXM52fbY7H/vfnvGhA2+7dG7c1YpptGHYwnbah2c3CQstZOXBtvcYooals4ZIOS/84rYw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2DyOS15x6WuRrJNDXu4hHcktucwyHWSJZB+QG+Dez8gIgMAaWquIuZPQKcbOtAeDmFcJmutc6bwlgapEhtUPyR7c="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"pkrumins","email":"peteris.krumins@gmail.com"},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}]}},"maintainers":[{"name":"pkrumins","email":"peteris.krumins@gmail.com"}],"time":{"modified":"2022-06-24T05:12:29.367Z","created":"2011-02-07T01:31:27.473Z","1.0.0":"2011-02-07T01:31:27.473Z","1.0.1":"2011-02-07T01:31:27.473Z","1.0.2":"2011-02-07T01:31:27.473Z","1.0.3":"2011-02-07T01:31:27.473Z","2.0.0":"2011-02-07T01:31:27.473Z","2.0.1":"2011-11-21T11:06:50.697Z","2.1.0":"2011-12-15T15:41:10.511Z","2.1.1":"2012-02-01T21:56:22.024Z","3.0.0":"2013-04-18T16:05:51.373Z","3.0.1":"2013-05-14T17:22:04.976Z","3.0.2":"2013-05-24T18:27:47.035Z","3.0.3":"2013-10-06T00:02:58.591Z"},"author":{"name":"Peteris Krumins","email":"peteris.krumins@gmail.com","url":"http://www.catonmat.net"},"repository":{"type":"git","url":"http://github.com/pkrumins/node-png.git"},"readme":"node-png\r\n--------\r\n\r\nThis is a node.js module, writen in C++, that uses libpng to produce a PNG\r\nimage (in memory) from RGB or RGBA buffers.\r\n\r\nThe module exports three objects: `Png`, `FixedPngStack` and `DynamicPngStack`.\r\n\r\nThe `Png` object is for creating PNG images from an RGB, RGBA, or Grayscale buffer.\r\nThe `FixedPngStack` is for joining a number of PNGs together (stacking them\r\ntogether) on a transparent blackground.\r\nThe `DynamicPngStack` is for joining a number of PNGs together in the most\r\nspace efficient way (so that the canvas border matches the leftmost upper corner\r\nof some PNG and the rightmost bottom corner of some PNG).\r\n\r\n\r\nPng\r\n---\r\n\r\nThe `Png` object takes 5 arguments in its constructor:\r\n\r\n``` javascript\r\nvar png = new Png(buffer, width, height, buffer_type, bits_per_pixel);\r\n```\r\n\r\nThe first argument, `buffer`, is a node.js `Buffer` filled with RGB(A) values.\r\nThe second argument is integer width of the image.\r\nThe third argument is integer height of the image.\r\nThe fourth argument is 'rgb', 'bgr', 'rgba', 'bgra', or 'gray'. Defaults to 'rgb'.\r\nThe fifth argument is valid only when buffer_type='gray'. Valid arguments are 8 (default) and 16.\r\n\r\nThe constructed `png` object has the `encode` method that's asynchronous in nature.\r\nYou give it a callback and it will call your function with a node.js Buffer object\r\ncontaining the encoded PNG data when it's done:\r\n\r\n``` javascript\r\npng.encode(function (png_image) {\r\n    // ...\r\n});\r\n```\r\n\r\nThe constructed `png` object also has `encodeSync` method that does the encoding\r\nsynchronously and returns Buffer with PNG image data:\r\n\r\n``` javascript\r\nvar png_image = png.encode();\r\n```\r\n\r\nYou can either send the png_image to the browser, or write to a file, or\r\ndo something else with it. See `examples/` directory for some examples.\r\n\r\n\r\nFixedPngStack\r\n-------------\r\n\r\nThe `FixedPngStack` object takes 3 arguments in its constructor:\r\n\r\n``` javascript\r\nvar fixed_png = new FixedPngStack(width, height, buffer_type);\r\n```\r\n\r\nThe first argument is integer width of the canvas image.\r\nThe second argument is integer height of the canvas image.\r\nThe third argument is 'rgb', 'bgr', 'rgba or 'bgra'. Defaults to 'rgb'.\r\n\r\nNow you can use the `push` method of `fixed_png` object to push buffers\r\nto the canvas. The `push` method takes 5 arguments:\r\n\r\n``` javascript\r\nfixed_png.push(buffer, x, y, w, h);\r\n```\r\n\r\nIt pushes an RGB(A) image in `buffer` of width `w` and height `h` to the canvas\r\nposition (x, y). You can push as many buffers to canvas as you want. After\r\nthat you should call `encode` method or `encodeSync` method that will join all\r\nthe pushed RGB(A) buffers together and return a single PNG.\r\n\r\nAll the regions that did not get covered will be transparent.\r\n\r\n\r\nDynamicPngStack\r\n---------------\r\n\r\nThe `DynamicPngStack` object doesn't take any dimension arguments because its\r\nwidth and height is dynamically computed. To create it, do:\r\n\r\n``` javascript\r\nvar dynamic_png = new DynamicPngStack(buffer_type);\r\n```\r\n\r\nThe `buffer_type` again is 'rgb', 'bgr', 'rgba' or 'bgra', depending on what type\r\nof buffers you're gonna push to `dynamic_png`.\r\n\r\nIt provides four methods - `push`, `encode`, `encodeSync`, and `dimensions`. The\r\n`push` and `encode` methods are the same as in `FixedPngStack`. You `push` each\r\nof the RGB(A) buffers to the stack and after that you call `encode` or\r\n`encodeSync`.\r\n\r\nThe `encode` asynchronous method receives one more argument than others - it\r\nreceives the dimensions object with x, y, width and height of the dynamic PNG.\r\nSee the next paragraph for what the dimensions are.\r\n\r\nThe `dimensions` method is more interesting. It must be called only after\r\n`encode` as its values are calculated upon encoding the image. It returns an\r\nobject with `width`, `height`, `x` and `y` properties. The `width` and\r\n`height` properties show the width and the height of the final image. The `x`\r\nand `y` propreties show the position of the leftmost upper PNG.\r\n\r\nHere is an example that illustrates it. Suppose you wish to join two PNGs\r\ntogether. One with width 100x40 at position (5, 10) and the other with\r\nwidth 20x20 at position (2, 210). First you create the DynamicPngStack\r\nobject:\r\n\r\n``` javascript\r\nvar dynamic_png = new DynamicPngStack();\r\n```\r\n\r\nNext you push the RGB(A) buffers of the two PNGs to it:\r\n\r\n``` javascript\r\ndynamic_png.push(png1_buf, 5, 10, 100, 40);\r\ndynamic_png.push(png2_buf, 2, 210, 20, 20);\r\n```\r\n\r\nNow you can call `encode` to produce the final PNG:\r\n\r\n``` javascript\r\nvar png = dynamic_png.encodeSync();\r\n```\r\n\r\nNow let's see what the dimensions are,\r\n\r\n``` javascript\r\nvar dims = dynamic_png.dimensions();\r\n```\r\n\r\nSame asynchronously:\r\n\r\n``` javascript\r\ndynamic_png.encode(function (png, dims) {\r\n    // png is the PNG image (in a node.js Buffer)\r\n    // dims are its dimensions\r\n});\r\n```\r\n\r\nThe x position `dims.x` is 2 because the 2nd png is closer to the left.\r\nThe y position `dims.y` is 10 because the 1st png is closer to the top.\r\nThe width `dims.width` is 103 because the first png stretches from x=5 to\r\nx=105, but the 2nd png starts only at x=2, so the first two pixels are not\r\nnecessary and the width is 105-2=103.\r\nThe height `dims.height` is 220 because the 2nd png is located at 210 and\r\nits height is 20, so it stretches to position 230, but the first png starts\r\nat 10, so the upper 10 pixels are not necessary and height becomes 230-10= 220.\r\n\r\n\r\nHow to compile?\r\n---------------\r\n\r\nTo get the node-png module compiled, you need to have libpng and node.js\r\ninstalled. Then just run:\r\n\r\n``` bash\r\n    node-gyp configure build\r\n```\r\n\r\nto build node-png module. It will be called `png.node`. To use it, make sure\r\nit's in NODE_PATH.\r\n\r\nSee also http://github.com/pkrumins/node-jpeg module that produces JPEG images.\r\nAnd also http://github.com/pkrumins/node-gif for producing GIF images.\r\n\r\nIf you wish to stream PNGs over a websocket or xhr-multipart, you'll have to\r\nbase64 encode it. Use my http://github.com/pkrumins/node-base64 module to do\r\nthat.\r\n\r\n","readmeFilename":"readme.md","users":{"pandao":true,"krot47":true}}