screenlib
v0.2.8
Published
Screenlib is a TypeScript library designed for capturing screenshots of web pages using various browser engines. It provides a simple and efficient way to programmatically take screenshots for testing, documentation, thumbnails or other purposes.
Readme
Screenlib
Screenlib is a TypeScript library designed for capturing screenshots of web pages using various browser engines. It provides a simple and efficient way to programmatically take screenshots for testing, documentation, thumbnails or other purposes.
Features
- Support for multiple browser engines (See Supported Browsers)
- Easy-to-use API for capturing screenshots
- Automatic browser download and management
Supported Browsers
| | Linux | Windows | macOS | | | ------- | ----- | ------- | ----- | ------- | | Servo | ✅ | ✅ | ❌ | Default | | Chrome | ❌ | ❌ | ❌ | WIP | | Firefox | ❌ | ❌ | ❌ | WIP | | WebKit | ❌ | ❌ | ❌ | WIP |
Installation
You can install screenlib using your favorite package manager.
NPM:
npm install screenlibBun:
bun add screenlibYarn:
yarn add screenlibUsage
Capture URL:
import { captureUrl } from "screenlib";
await captureUrl("https://npmjs.com/package/screenlib", {
output: "screenshot.png",
});Capture file:
import { captureFile } from "screenlib";
await captureFile("path/to/file.html", {
output: "screenshot.png",
});Capture HTML string:
import { captureHtml } from "screenlib";
await captureHtml("<html><body><h1>Hello, world!</h1></body></html>", {
output: "screenshot.png",
});Set dimensions:
import { captureUrl } from "screenlib";
await captureUrl("https://npmjs.com/package/screenlib", {
output: "screenshot.png",
width: 1280,
height: 720,
});Set browser:
import { captureUrl, Browser } from "screenlib";
await captureUrl("https://npmjs.com/package/screenlib", {
output: "screenshot.png",
browser: Browser.Servo,
});Authors
- Martin Petr
- Github: @MartinGamesCZ
- Website: martinpetr.dev
