forked from Automattic/node-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.json
More file actions
68 lines (68 loc) · 11.8 KB
/
package.json
File metadata and controls
68 lines (68 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"name": "canvas",
"description": "Canvas graphics API backed by Cairo",
"version": "1.2.7",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@learnboost.com"
},
"contributors": [
{
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net"
},
{
"name": "Rod Vagg",
"email": "r@va.gg"
},
{
"name": "Juriy Zaytsev",
"email": "kangax@gmail.com"
}
],
"keywords": [
"canvas",
"graphic",
"graphics",
"pixman",
"cairo",
"image",
"images",
"pdf"
],
"homepage": "https://github.com/Automattic/node-canvas",
"repository": {
"type": "git",
"url": "git://github.com/Automattic/node-canvas.git"
},
"scripts": {
"test": "make test",
"install": "node-gyp rebuild"
},
"dependencies": {
"nan": "^1.8.4",
"opentype.js": "0.4.x"
},
"devDependencies": {
"body-parser": "^1.13.3",
"express": "^4.13.2",
"jade": "^1.11.0",
"mocha": "*"
},
"engines": {
"node": ">=0.8.0 <3"
},
"main": "./lib/canvas.js",
"license": "MIT",
"gypfile": true,
"gitHead": "6a47205a6b490e1e49f867162edd7a207f40f9a1",
"readme": "node-canvas\n===========\n### Canvas graphics API backed by Cairo\n[](https://travis-ci.org/Automattic/node-canvas)\n[](http://badge.fury.io/js/canvas)\n\n node-canvas is a [Cairo](http://cairographics.org/) backed Canvas implementation for [NodeJS](http://nodejs.org).\n\n## Authors\n\n - TJ Holowaychuk ([tj](http://github.com/tj))\n - Nathan Rajlich ([TooTallNate](http://github.com/TooTallNate))\n - Rod Vagg ([rvagg](http://github.com/rvagg))\n - Juriy Zaytsev ([kangax](http://github.com/kangax))\n\n## Installation\n\n```bash\n$ npm install canvas\n```\n\nUnless previously installed you'll _need_ __Cairo__. For system-specific installation view the [Wiki](https://github.com/LearnBoost/node-canvas/wiki/_pages).\n\nYou can quickly install Cairo and its dependencies for OS X using the one liner below:\n\n```bash\n$ wget https://raw.githubusercontent.com/LearnBoost/node-canvas/master/install -O - | sh\n```\n\nor if you use MacPorts\n\n```bash\nsudo port install pkgconfig libpng giflib freetype libpixman cairo\n```\n\n## Screencasts\n\n - [Introduction](http://screenr.com/CTk)\n\n## Example\n\n```javascript\nvar Canvas = require('canvas')\n , Image = Canvas.Image\n , canvas = new Canvas(200, 200)\n , ctx = canvas.getContext('2d');\n\nctx.font = '30px Impact';\nctx.rotate(.1);\nctx.fillText(\"Awesome!\", 50, 100);\n\nvar te = ctx.measureText('Awesome!');\nctx.strokeStyle = 'rgba(0,0,0,0.5)';\nctx.beginPath();\nctx.lineTo(50, 102);\nctx.lineTo(50 + te.width, 102);\nctx.stroke();\n\nconsole.log('<img src=\"' + canvas.toDataURL() + '\" />');\n```\n\n## Non-Standard API\n\n node-canvas extends the canvas API to provide interfacing with node, for example streaming PNG data, converting to a `Buffer` instance, etc. Among the interfacing API, in some cases the drawing API has been extended for SSJS image manipulation / creation usage, however keep in mind these additions may fail to render properly within browsers.\n\n### Image#src=Buffer\n\n node-canvas adds `Image#src=Buffer` support, allowing you to read images from disc, redis, etc and apply them via `ctx.drawImage()`. Below we draw scaled down squid png by reading it from the disk with node's I/O.\n\n```javascript\nfs.readFile(__dirname + '/images/squid.png', function(err, squid){\n if (err) throw err;\n img = new Image;\n img.src = squid;\n ctx.drawImage(img, 0, 0, img.width / 4, img.height / 4);\n});\n```\n\n Below is an example of a canvas drawing it-self as the source several time:\n\n```javascript\nvar img = new Image;\nimg.src = canvas.toBuffer();\nctx.drawImage(img, 0, 0, 50, 50);\nctx.drawImage(img, 50, 0, 50, 50);\nctx.drawImage(img, 100, 0, 50, 50);\n```\n\n### Image#dataMode\n\nnode-canvas adds `Image#dataMode` support, which can be used to opt-in to mime data tracking of images (currently only JPEGs).\n\nWhen mime data is tracked, in PDF mode JPEGs can be embedded directly into the output, rather than being re-encoded into PNG. This can drastically reduce filesize, and speed up rendering.\n\n```javascript\nvar img = new Image;\nimg.dataMode = Image.MODE_IMAGE; // Only image data tracked\nimg.dataMode = Image.MODE_MIME; // Only mime data tracked\nimg.dataMode = Image.MODE_MIME | Image.MODE_IMAGE; // Both are tracked\n```\n\nIf image data is not tracked, and the Image is drawn to an image rather than a PDF canvas, the output will be junk. Enabling mime data tracking has no benefits (only a slow down) unless you are generating a PDF.\n\n### Canvas#pngStream()\n\n To create a `PNGStream` simply call `canvas.pngStream()`, and the stream will start to emit _data_ events, finally emitting _end_ when finished. If an exception occurs the _error_ event is emitted.\n\n```javascript\nvar fs = require('fs')\n , out = fs.createWriteStream(__dirname + '/text.png')\n , stream = canvas.pngStream();\n\nstream.on('data', function(chunk){\n out.write(chunk);\n});\n\nstream.on('end', function(){\n console.log('saved png');\n});\n```\n\nCurrently _only_ sync streaming is supported, however we plan on supporting async streaming as well (of course :) ). Until then the `Canvas#toBuffer(callback)` alternative is async utilizing `eio_custom()`.\n\n### Canvas#jpegStream() and Canvas#syncJPEGStream()\n\nYou can likewise create a `JPEGStream` by calling `canvas.jpegStream()` with\nsome optional parameters; functionality is otherwise identical to\n`pngStream()`. See `examples/crop.js` for an example.\n\n_Note: At the moment, `jpegStream()` is the same as `syncJPEGStream()`, both\nare synchronous_\n\n```javascript\nvar stream = canvas.jpegStream({\n bufsize: 4096 // output buffer size in bytes, default: 4096\n , quality: 75 // JPEG quality (0-100) default: 75\n , progressive: false // true for progressive compression, default: false\n});\n```\n\n### Canvas#toBuffer()\n\nA call to `Canvas#toBuffer()` will return a node `Buffer` instance containing all of the PNG data.\n\n```javascript\ncanvas.toBuffer();\n```\n\n### Canvas#toBuffer() async\n\nOptionally we may pass a callback function to `Canvas#toBuffer()`, and this process will be performed asynchronously, and will `callback(err, buf)`.\n\n```javascript\ncanvas.toBuffer(function(err, buf){\n\n});\n```\n\n### Canvas#toDataURL() async\n\nOptionally we may pass a callback function to `Canvas#toDataURL()`, and this process will be performed asynchronously, and will `callback(err, str)`.\n\n```javascript\ncanvas.toDataURL(function(err, str){\n\n});\n```\n\nor specify the mime type:\n\n```javascript\ncanvas.toDataURL('image/png', function(err, str){\n\n});\n```\n\n### CanvasRenderingContext2d#patternQuality\n\nGiven one of the values below will alter pattern (gradients, images, etc) render quality, defaults to _good_.\n\n - fast\n - good\n - best\n - nearest\n - bilinear\n\n### CanvasRenderingContext2d#textDrawingMode\n\nCan be either `path` or `glyph`. Using `glyph` is much faster than `path` for drawing, and when using a PDF context will embed the text natively, so will be selectable and lower filesize. The downside is that cairo does not have any subpixel precision for `glyph`, so this will be noticeably lower quality for text positioning in cases such as rotated text. Also, strokeText in `glyph` will act the same as fillText, except using the stroke style for the fill.\n\nDefaults to _path_.\n\nThis property is tracked as part of the canvas state in save/restore.\n\n### CanvasRenderingContext2d#filter\n\nLike `patternQuality`, but applies to transformations effecting more than just patterns. Defaults to _good_.\n\n - fast\n - good\n - best\n - nearest\n - bilinear\n\n### Global Composite Operations\n\nIn addition to those specified and commonly implemented by browsers, the following have been added:\n\n - multiply\n - screen\n - overlay\n - hard-light\n - soft-light\n - hsl-hue\n - hsl-saturation\n - hsl-color\n - hsl-luminosity\n\n## Anti-Aliasing\n\n Set anti-aliasing mode\n\n - default\n - none\n - gray\n - subpixel\n\n For example:\n\n```javascript\nctx.antialias = 'none';\n```\n\n## PDF Support\n\n Basic PDF support was added in 0.11.0. Make sure to install cairo with `--enable-pdf=yes` for the PDF backend. node-canvas must know that it is creating\n a PDF on initialization, using the \"pdf\" string:\n\n```js\nvar canvas = new Canvas(200, 500, 'pdf');\n```\n\n An additional method `.addPage()` is then available to create\n multiple page PDFs:\n\n```js\nctx.font = '22px Helvetica';\nctx.fillText('Hello World', 50, 80);\nctx.addPage();\n\nctx.font = '22px Helvetica';\nctx.fillText('Hello World 2', 50, 80);\nctx.addPage();\n\nctx.font = '22px Helvetica';\nctx.fillText('Hello World 3', 50, 80);\nctx.addPage();\n```\n\n## SVG support\n\n Just like PDF support, make sure to install cairo with `--enable-svg=yes`.\n You also need to tell node-canvas that it is working on SVG upon its initialization:\n\n```js\nvar canvas = new Canvas(200, 500, 'svg');\n// Use the normal primitives.\nfs.writeFile('out.svg', canvas.toBuffer());\n```\n\n## Benchmarks\n\n Although node-canvas is extremely new, and we have not even begun optimization yet it is already quite fast. For benchmarks vs other node canvas implementations view this [gist](https://gist.github.com/664922), or update the submodules and run `$ make benchmark` yourself.\n\n## Contribute\n\n Want to contribute to node-canvas? patches for features, bug fixes, documentation, examples and others are certainly welcome. Take a look at the [issue queue](https://github.com/LearnBoost/node-canvas/issues) for existing issues.\n\n## Examples\n\n Examples are placed in _./examples_, be sure to check them out! most produce a png image of the same name, and others such as _live-clock.js_ launch an http server to be viewed in the browser.\n\n## Testing\n\nIf you have not previously, init git submodules:\n\n $ git submodule update --init\n\nInstall the node modules:\n\n $ npm install\n\nBuild node-canvas:\n\n $ node-gyp rebuild\n\nUnit tests:\n\n $ make test\n\nVisual tests:\n\n $ make test-server\n\n## Versions\n\nTested with and designed for:\n\n - node 0.4.2\n - cairo 1.8.6\n\nFor node 0.2.x `node-canvas` <= 0.4.3 may be used,\n0.5.0 and above are designed for node 0.4.x only.\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010 LearnBoost, and contributors <dev@learnboost.com>\n\nCopyright (c) 2014 Automattic, Inc and contributors <dev@automattic.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/Automattic/node-canvas/issues"
},
"_id": "canvas@1.2.7",
"_shasum": "41c2f5a44834928133e7be3197549c2a5d089fa4",
"_from": "git://github.com/sepehr-laal/node-canvas.git#master",
"_resolved": "git://github.com/sepehr-laal/node-canvas.git#6a47205a6b490e1e49f867162edd7a207f40f9a1"
}