{"_id":"@bananocoin/pureimage","_rev":"2-84accc28f52782eb74dcffb2af7903f1","name":"@bananocoin/pureimage","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.3":{"name":"@bananocoin/pureimage","version":"0.1.3","description":"Pure JS image drawing API based on Canvas. Export to PNG streams.","author":{"name":"Josh Marinacci","email":"joshua@marinacci.org","url":"http://joshondesign.com/"},"main":"./src/pureimage.js","repository":{"type":"git","url":"git+https://github.com/joshmarinacci/node-pureimage.git"},"dependencies":{"jpeg-js":"^0.3.6","opentype.js":"^1.1.0","pngjs":"^3.2.0"},"devDependencies":{"eslint":"^6.8.0","eslint-config-google":"^0.14.0","tape":"^4.13.0"},"scripts":{"test":"node tests/runtests.js"},"gitHead":"8087e415bba19ff59eaa41e4616a977914700c71","bugs":{"url":"https://github.com/joshmarinacci/node-pureimage/issues"},"homepage":"https://github.com/joshmarinacci/node-pureimage#readme","_id":"@bananocoin/pureimage@0.1.3","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-DKK/k0sa1Rs6H+wF5JJg/v+J3cwmD/0oOudt4gA1BJbMDYXcxZGbDU3ez8Jg5TvOnuU7Cx5TzxDus3Q9fbIYeg==","shasum":"ec826818f9eb5c542327afd415d112057a68e759","tarball":"https://registry.npmjs.org/@bananocoin/pureimage/-/pureimage-0.1.3.tgz","fileCount":73,"unpackedSize":1165095,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeLfurCRA9TVsSAnZWagAApzcP/jtp/pzsU5rsiZIbwGoQ\nBpFpLaNOrJy017GTNwiE07wuZ4FUwnpZ7CRZ+asY7MKbryOhdlvMSmDdJ/ae\n3ACY+Sj4W907pbdica5eLqA1lWSiObvUJhgKUh+SUtt9xvwnWwTHec+hJ+gI\nTERAPt7uUDC83DqttSXCIyA8hoobjfx+IIl1RTu3HEJOnIpeeVG5Cj0I3MTE\nN3nNvd1JERF3iICygkB72CiZ+v5+vXB4iiAgOuVAN4e7lP26hTnyT6VofNoA\njXeITwtu/KJEM2aADGjafKEYQE7lRX8ngzHpQ3KIYHN+bDZFEMjXsrM05I7k\na1ZPVgqo8QUZz5P+2ILpFU+Yb6HOjGpma0DUNKxD5oZpkQbSD0Fjp5V3DZ7Z\nHEje2neV7uJFucpx6GPEPW8eA2Zngn+gqVCGHJ25nWMX4+xQACghEy8pTN5R\nWwNuJ1G2vEI/ES1sfH5KdsBiw5E19dx4B3/Nu6ASeHK+rx0bV5T1QVn9RpEK\niKmVV0Dc/OwFN8lYJ9LwPuYrdNb36urCKxbWhRGEmjQqCEI0yUVU8cLPJv8D\nWTuairELqS+OQYa4RWsS7/Fa3e+shzyCDnmUTkUVERSb0z3eMsXhKqpmh1xf\nE3pVmted60L5DGBuIu2v+x7T3IcwwvqT1EpiXAi90lv0mbM55GJMXNWNeIwF\nTgKC\r\n=zfXM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC6uqsxo930Tn99mHDp+bZsqzf98lDESbZOrduSZ2kekAiEAgrpZqN/ru0ML03hyP1dgkL4M1yrLpDgOFEKs67yzsg8="}]},"maintainers":[{"name":"coranos","email":"elastos.ledger@gmail.com"}],"_npmUser":{"name":"coranos","email":"elastos.ledger@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pureimage_0.1.3_1580071851226_0.7936107862128317"},"_hasShrinkwrap":false}},"time":{"created":"2020-01-26T20:50:50.969Z","0.1.3":"2020-01-26T20:50:51.407Z","modified":"2023-06-15T12:55:31.725Z"},"maintainers":[{"email":"dev.ptera@gmail.com","name":"dev-ptera"},{"email":"bananonpm@gmail.com","name":"coranos"}],"description":"Pure JS image drawing API based on Canvas. Export to PNG streams.","homepage":"https://github.com/joshmarinacci/node-pureimage#readme","repository":{"type":"git","url":"git+https://github.com/joshmarinacci/node-pureimage.git"},"author":{"name":"Josh Marinacci","email":"joshua@marinacci.org","url":"http://joshondesign.com/"},"bugs":{"url":"https://github.com/joshmarinacci/node-pureimage/issues"},"readme":"PureImage\n==============\n\nPureImage is a pure JavaScript implementation of the HTML Canvas 2d drawing api for NodeJS. \nIt has no native dependencies.\n\nNew 0.1.x release\n=================\n\nI've completely refactored the code so that it should be easier to \nmaintain and implement new features. For the most part there are no API changes (since the API is\n defined by the HTML Canvas spec), but if you\nwere using the font or image loading extensions\nyou will need to use the new function names and switch to promises. \n\nI'm also using Node buffers instead of arrays internally, so you can work with large images \nfaster than before. Rich text is no longer supported, which is fine because it never really worked\nanyway. We'll have to find a different way to do it.\n\nI've tried to maintain all of the patches that have been sent in, but if you contributed a patch \nplease check that it still works. Thank you all!  - josh \n\n\n## supported Canvas Features\n\n* set pixels\n* stroke and fill paths (rectangles, lines, quadratic curves, bezier curves, arcs/circles)\n* copy and scale images (nearest neighbor)\n* import and export JPG and PNG from streams using promises\n* render basic text (no bold or italics yet)\n* anti-aliased strokes and fills\n* transforms\n* standard globalAlpha and rgba() alpha compositing\n* clip shapes\n\n\nOn the roadmap, but still missing\n=================================\n\n* gradients fills\n* image fills\n* blend modes besides SRC OVER\n* smooth clip shapes\n* bold/italic fonts\n* measure text\n* smooth image interpolation\n\n\nWhy?\n====\n\nThe are more than enough drawing APIs out there. Why do we need another? My\npersonal hatred of C/C++ compilers is [widely known](https://joshondesign.com/2014/09/17/rustlang). \nThe popular Node modules [Canvas.js](https://github.com/Automattic/node-canvas) does a great\njob, but it's backed by Cairo, a C/C++ layer. I hate having native dependencies\nin Node modules. They often don't compile, or break after a system update. They\noften don't support non-X86 architectures (like the Raspberry Pi). You have\nto have a compiler already installed to use them, along with any other native\ndependencies pre-installed (like Cairo).  \n\nSo, I made PureImage. It's goal is to implement the HTML Canvas spec in a headless\nNode buffer. No browser or window required.\n\nPureImage is meant to be a small and maintainable Canvas library.\nIt is *not meant to be fast*.  If there are two choices of algorithm we will\ntake the one with the simplest implementation, and preferably the fewest lines.\nWe avoid special cases and optimizations to keep the code simple and maintainable.\nIt should run everywhere and be always produce the same output. But it will not be \nfast. If you need speed go use something else.\n\nPureImage uses only pure JS dependencies.  [OpenType](https://github.com/nodebox/opentype.js/)\nfor font parsing, [PngJS](https://github.com/niegowski/node-pngjs) for PNG import/export, \nand [jpeg-js](https://github.com/eugeneware/jpeg-js) for JPG import/export.\n\n\n\nExamples\n=========\n\n\nMake a new empty image, 100px by 50px. Automatically filled with 100% opaque black.\n\n```\nvar PImage = require('pureimage');\nvar img1 = PImage.make(100,50);\n```\n\nFill with a red rectangle with 50% opacity\n\n```\nvar ctx = img1.getContext('2d');\nctx.fillStyle = 'rgba(255,0,0, 0.5)';\nctx.fillRect(0,0,100,100);\n```\n\nFill a green circle wiwth a radius of 40 pixels in the middle of a 100px square black image.\n\n```\n    var img = PImage.make(100,100);\n    var ctx = img.getContext('2d');\n    ctx.fillStyle = '#00ff00';\n    ctx.beginPath();\n    ctx.arc(50,50,40,0,Math.PI*2,true); // Outer circle\n    ctx.closePath();\n    ctx.fill();\n```\n\n![image of arcto with some fringing bugs](firstimages/arcto.png)\n\nDraw the string 'ABC' in white in the font 'Source Sans Pro', loaded from disk, at a size\nof 48 points. \n\n```\ntest('font test', (t) => {\n    var fnt = PImage.registerFont('tests/fonts/SourceSansPro-Regular.ttf','Source Sans Pro');\n    fnt.load(function() {\n        var img = PImage.make(200,200);\n        var ctx = img.getContext('2d');\n        ctx.fillStyle = '#ffffff';\n        ctx.font = \"48pt 'Source Sans Pro'\";\n        ctx.fillText(\"ABC\", 80, 80);\n    });\n});\n```\n\n\nWrite out to a PNG file\n\n```\nPImage.encodePNGToStream(img1, fs.createWriteStream('out.png')).then(()=> {\n    console.log(\"wrote out the png file to out.png\");\n}).catch((e)=>{\n    console.log(\"there was an error writing\");\n});\n```\n\nRead a jpeg, resize it, then save it out\n\n```\nPImage.decodeJPEGFromStream(fs.createReadStream(\"tests/images/bird.jpg\")).then((img)=>{\n    console.log(\"size is\",img.width,img.height);\n    var img2 = PImage.make(50,50);\n    var c = img2.getContext('2d');\n    c.drawImage(img,\n        0, 0, img.width, img.height, // source dimensions\n        0, 0, 50, 50   // destination dimensions\n    );\n    var pth = path.join(BUILD_DIR,\"resized_bird.jpg\");\n    PImage.encodeJPEGToStream(img2,fs.createWriteStream(pth)).then(()=> {\n        console.log(\"done writing\");\n    });\n```\n\n\n\nThanks!\n===============\n\nThanks to Nodebox / EMRG for [opentype.js](https://github.com/nodebox/opentype.js/)\n\nThanks to Rosetta Code for [Bresenham's in JS](http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#JavaScript)\n\nThanks to Kuba Niegowski for [PngJS](https://github.com/niegowski/node-pngjs)\n\nThanks to Eugene Ware for [jpeg-js]( https://github.com/eugeneware/jpeg-js )\n\nThanks for patches from:\n\n* Dan [danielbarela](https://github.com/danielbarela)\n* Eugene Kulabuhov [ekulabuhov](https://github.com/ekulabuhov)\n* Lethexa [lethexa](https://github.com/lethexa)\n* The Louie [the-louie](https://github.com/the-louie)\n* Jan Marsch [kekscom](https://github.com/kekscom)\n* \n","readmeFilename":"README.md"}