Files
http2pic/README.md
Chris 7360d0b08a
All checks were successful
Build Container / docker (push) Successful in 4m13s
feat: add fullpage and maxheight parameters for enhanced screenshot options
2026-04-24 15:43:08 +02:00

89 lines
2.9 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# http2pic
## Introduction
http2pic is an Open Source website renderer. It uses the [wkhtmltox](https://github.com/wkhtmltopdf/wkhtmltopdf) to render websites with various options.
Live demo on https://http2pic.haschek.at/
## Dependencies
- [wkhtmltox](http://wkhtmltopdf.org/downloads.html)
- curl extension for PHP ```apt-get install php5-curl```
- Make sure the server has the "timeout" command ```apt-get install coreutils```
## Install
- Download [this repo](https://github.com/chrisiaut/http2pic/archive/master.zip) and extract it somewhere on your webserver
### With WKHTMLToImage
- Install [wkhtmltox](http://wkhtmltopdf.org/downloads.html) on your server
- Make /usr/sbin/wkhtmltoimage executable for the user that runs the webserver. For Apache it's the ```www-data``` user. Or use sudo
### With PhantomJS
- Install PhantomJS. eg via ```npm install -g phantomjs```
- Make /usr/bin/phantomjs executable for the user that runs the webserver. For Apache it's the ```www-data``` user. Or use sudo
## Upgrade
Whenever you come to this page you can just [download](https://github.com/chrisiaut/http2pic/archive/master.zip) the repo again and overwrite the existing files. Should work out of the box
## Usage
```
https://your-host/api?url=[WEBSITE_URL]&[OPTIONS]
```
### Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| `url` | — | Target URL to screenshot (required) |
| `viewport` | `1024x768` | Viewport size as `WIDTHxHEIGHT` (max 3840x2160) |
| `js` | `true` | Enable JavaScript (`true`/`false`) |
| `fullpage` | `false` | Capture full page height instead of viewport only |
| `maxheight` | `15000` | Max pixel height for full-page captures (130000) |
| `key` | — | API key (if `API_KEY` env var is set) |
### Examples
```bash
# Standard viewport screenshot
curl "https://your-host/api?url=https://example.com" -o screenshot.png
# Full-page screenshot (great for LLM analysis)
curl "https://your-host/api?url=https://example.com&fullpage=true" -o full.png
# Full-page with custom width and height cap
curl "https://your-host/api?url=https://example.com&fullpage=true&viewport=1280x768&maxheight=20000" -o full.png
# With API key
curl -H "X-API-Key: your-secret" "https://your-host/api?url=https://example.com&fullpage=true" -o full.png
```
Use as an `<img>` src:
```html
<img src="https://your-host/api?url=https://example.com" title="screenshot" />
```
### Example php script to proxy an image to the local server
```php
<?php
$targeturl = 'http://www.xkcd.com';
$url = 'https://http2pic.haschek.at/api.php?url='.rawurlencode($targeturl);
$ch = curl_init($url);
$fp = fopen('xkcd.jpg', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
```
---
This is a [HASCHEK SOLUTIONS](https://haschek.solutions) project
[![HS logo](https://http2pic.haschek.at/img/hs_logo.png)](https://haschek.solutions)