New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

canvas-screenshot

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-screenshot

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

  • 4.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
90
decreased by-18.18%
Maintainers
1
Weekly downloads
 
Created
Source

canvas-screenshot

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

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

paypal coinbase twitter

Installation

npm install canvas-screenshot

Usage

import canvasScreenshot from "canvas-screenshot";
import canvasContext from "canvas-context";

// Create
const { context, canvas } = canvasContext("2d", {
  width: 100,
  height: 100,
});

// Draw
context.fillStyle = "salmon";
context.fillRect(40, 40, 20, 20);

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

API

Modules

canvasScreenshot

Typedefs

CanvasScreenshotOptions : object

Options for canvas screenshot. All optional.

canvasScreenshot

canvasScreenshot(canvas, [options]) ⇒ string | Promise.<Blob>

Take a screenshot. Setting options.useBlob to true will consequently make the module async and return the latter.

Kind: Exported function Returns: string | Promise.<Blob> - A DOMString or a Promise resolving with a Blob.

Type is inferred from the filename extension:

  • png for "image/png" (default)
  • jpg/jpeg for "image/jpeg"
  • webp for "image/webp"
ParamTypeDefaultDescription
canvasHTMLCanvasElementThe canvas element
[options]CanvasScreenshotOptions{}

CanvasScreenshotOptions : object

Options for canvas screenshot. All optional.

Kind: global typedef Properties

NameTypeDefaultDescription
[filename]string"Screen Shot YYYY-MM-DD at HH.MM.SS.png"File name.
[quality]number1Quality between 0 and 1.
[useBlob]booleanUse canvas.toBlob.
[download]booleantrueAutomatically download the screenshot.

License

MIT. See license file.

Keywords

FAQs

Package last updated on 22 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc