Socket
Book a DemoInstallSign in
Socket

dom-to-images

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-to-images

dom-to-image but generates high-resolution images

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

dom-to-images

npm version

Usage

import { toPng, toJpeg, toBlob } from "dom-to-images"

const dataUrl = await toPng(el, options)
const dataUrl = await toJpeg(el, options)
const blob = await toBlob(el, options)

Options

export interface Options {
  filter?: (node: Node) => boolean
  bgcolor?: string
  width?: number
  height?: number
  style?: {}
  quality?: number
  imagePlaceholder?: string
  cacheBust?: boolean
}

Browser Support

<script type="module" src="https://unpkg.com/dom-to-images/dist/index.mjs"></script>

<script>
  DomToImage.toPng(document.body).then(function (dataUrl) {
    const a = document.createElement('a')
    a.download = 'image.png'
    a.href = dataUrl
    a.click()
  })
</script>

FAQs

Package last updated on 23 Nov 2023

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