Capture screenshots in Perl
Add screenshot and scrolling GIF capabilities to your Perl applications with LWP::UserAgent. Battle-tested, no headless browsers to manage.
Installation
- 1Install LWP: cpan LWP::UserAgent (often pre-installed)
- 2Get your API key from the dashboard
- 3Set the X-KEY header in your requests
Authentication
Include your API key in the X-KEY header with every request:
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $response = $ua->get($url,
'X-KEY' => 'your-api-key'
);Perl Screenshot Example
Capture a screenshot or create a scrolling GIF animation with a simple GET request:
use LWP::UserAgent;
use File::Slurp;
my $ua = LWP::UserAgent->new;
my $response = $ua->get(
'https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png',
'X-KEY' => 'your-api-key'
);
write_file('screenshot.png', {binmode => ':raw'}, $response->content);use LWP::UserAgent;
use File::Slurp;
my $ua = LWP::UserAgent->new;
my $response = $ua->get(
'https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out',
'X-KEY' => 'your-api-key'
);
write_file('animation.gif', {binmode => ':raw'}, $response->content);Response Format
On success, the API returns the image binary data directly in the response body.
| Status Code | 200 OK |
| Content-Type | image/png, image/jpeg, or image/gif |
| Body | Binary image data (scalar) |
| Error Response | Error message with 4xx/5xx status |
Key Features
Zero Setup
No need to install WWW::Mechanize::Chrome or manage browsers. Just use LWP::UserAgent for HTTP calls.
Production Ready
Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.
Perl Integration
Works with any Perl environment — Mojolicious, Catalyst, Dancer2, CGI, or plain Perl scripts.
Rich Features
Custom viewport sizes, full page capture, PNG/JPEG formats, scrolling GIFs with 15 easing functions.
Frequently Asked Questions
Do I need to install any browser dependencies for Perl?
No. Scrnpix runs browsers on our infrastructure. You only need LWP::UserAgent to make HTTP calls.
Can I use this with Mojolicious or Catalyst?
Yes. Scrnpix works with any Perl framework — Mojolicious, Catalyst, Dancer2, or plain Perl scripts.
How do I handle errors in Perl?
Check the response with is_success(). A 200 status means success with image bytes in content(). Use eval or Try::Tiny for error handling.
What Perl version is required?
Perl 5.16+ with LWP::UserAgent support. The API is a simple HTTP GET request.
Ready to capture screenshots in Perl?
Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.
Start Free