canvas-screenshot
A one trick pony package to download an image from a canvas.
Last updated 5 months ago by dmnsgn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install canvas-screenshot 
SYNC missed versions from official npm registry.

canvas-screenshot stable

npm version styled with prettier

A one trick pony package to download an image from a canvas.

Installation

npm install canvas-screenshot

NPM

Usage

const canvasScreenshot = require("canvas-screenshot");
const createCanvasContext = require("canvas-context");

const { context } = createCanvasContext("2d", {
  width: 100,
  height: 100
});

const button = document.createElement("button");
button.addEventListener("click", () => {
  canvasScreenshot(context.canvas);
});

API

canvasScreenshot(canvas, options): DOMString | Promise<Blob>

Returns a Data URI or a Promise resolving with a Blob. Setting useBlob to true will consequently make the module async and return the latter.

Option Type Default Description
canvas HTMLCanvasElement The canvas element
options.filename string? Screen Shot YYYY-MM-DD at HH.MM.SS.png File name
options.quality number? 1 Quality between 0 and 1
options.useBlob boolean? undefined Use canvas.toBlob
options.download boolean? true Automatically download the screenshot

Type is inferred from the filename extension (jpg/jpeg) for "image/jpeg" and default to "image/png".

License

MIT. See license file.

Current Tags

  • 3.0.0                                ...           latest (5 months ago)

5 Versions

  • 3.0.0                                ...           5 months ago
  • 2.0.0                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |