https://github.com/rgglez/webkit2png-daemon
Server written in Perl which uses webkit2png to take screenshots of webpages.
https://github.com/rgglez/webkit2png-daemon
daemon perl screenshot server webkit2png
Last synced: about 1 year ago
JSON representation
Server written in Perl which uses webkit2png to take screenshots of webpages.
- Host: GitHub
- URL: https://github.com/rgglez/webkit2png-daemon
- Owner: rgglez
- License: bsd-3-clause
- Created: 2023-04-17T07:18:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-20T04:03:42.000Z (about 3 years ago)
- Last Synced: 2025-01-28T01:44:31.201Z (over 1 year ago)
- Topics: daemon, perl, screenshot, server, webkit2png
- Language: Perl
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webkit2png-daemon
[](https://opensource.org/licenses/BSD-3-Clause)


A server daemon written in Perl which listens in an specified TCP port for a string containing the URL to be screenshoted. It uses the [WebKit2PNG](https://pypi.org/project/webkit2png/) script to make the screenshot.
You can configure the listening port, host and other parameters for the daemon using the [Net::Server configuration](https://metacpan.org/pod/Net::Server).
See the *run.sh* script for an example on how to run the daemon.
## Usage
Adjust the paths of the programs here:
```perl
my $PYTHON = '/usr/bin/python';
my $XVFB = '/usr/bin/xvfb-run';
my $WEBKIT2PNG = 'webkit2png.py';
my $CAT = '/bin/cat';
```
Create the directory for the logs and set the correct permissions/ownerships:
```bash
mkdir /var/log/webkit2png/
chown $USER:$GROUP /var/log/webkit2png/
```
Start the server executing:
```bash
perl WebKit2PNGDaemon.pl
```
Then send a string (the URL to be screenshoted) to the specified port and host. The server will execute WebKit2PNG and return a first line containing
```
LENGTH:
```
and then the bytes of the captured screen in PNG format, or an error image.
## Dependencies
### Perl modules
You can install them using *perl -MCPAN -e shell* or your distro's package manager:
* [Net::Server::PreFork](https://metacpan.org/pod/Net::Server::PreFork)
* [GD::Simple](https://metacpan.org/pod/GD::Simple)
* [File::Temp](https://perldoc.perl.org/File::Temp)
* [MIME::Base64](https://metacpan.org/pod/MIME::Base64)
* [Sys::Syslog](https://perldoc.perl.org/Sys::Syslog)
* [Digest::SHA](https://metacpan.org/pod/Digest::SHA)
* [Data::Validate::URI](https://metacpan.org/pod/Data::Validate::URI)
### Programs
* [WebKit2PNG](https://pypi.org/project/webkit2png/)
* [Python](https://www.python.org/)
* [xvfb-run](https://github.com/revnode/xvfb-run/blob/master/xvfb-run)
* [cat](https://man7.org/linux/man-pages/man1/cat.1.html)
## Notes
* You must download the [webkit2png](https://pypi.org/project/webkit2png/) Python script.
* If you are into cloud FaaS, look [here](https://github.com/rgglez/fc-webpage-screenshot).
## License
Copyright (c) 2023, Rodolfo González González.
Read the LICENSE file.