Socket
Socket
Sign inDemoInstall

canvas-screenshot

Package Overview
Dependencies
1
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

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.


Version published
Weekly downloads
93
decreased by-7%
Maintainers
1
Install size
15.9 kB
Created
Weekly downloads
 

Changelog

Source

4.2.0 (2024-01-22)

Features

  • add support for image/webp (b645d38)

Readme

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

Last updated on 22 Jan 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc