Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hunghg255/dom-to-images
Convert html to image
https://github.com/hunghg255/dom-to-images
dom-to-image html-to-image npm
Last synced: 3 months ago
JSON representation
Convert html to image
- Host: GitHub
- URL: https://github.com/hunghg255/dom-to-images
- Owner: hunghg255
- License: mit
- Created: 2023-10-28T11:31:02.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-23T05:04:10.000Z (about 1 year ago)
- Last Synced: 2023-11-23T06:22:40.128Z (about 1 year ago)
- Topics: dom-to-image, html-to-image, npm
- Language: TypeScript
- Homepage:
- Size: 16.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A library convert html to image## Usage
```ts
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
```ts
export interface Options {
filter?: (node: Node) => boolean
bgcolor?: string
width?: number
height?: number
style?: {}
quality?: number
imagePlaceholder?: string
cacheBust?: boolean
}
```## Browser Support
```html
DomToImage.toPng(document.body).then(function (dataUrl) {
const a = document.createElement('a')
a.download = 'image.png'
a.href = dataUrl
a.click()
})```