Fork me on GitHub

http2pic


Loading..


Give it a try!

How the API works

https://http2pic.haschek.at/api/?url=[WEBSITE_URL]&[OPTIONS]



Options

Option Values Description Example
url http://.. The URL of the webpage you'd like to take a screenshot of. Make sure to encode the URL! url=http://xkcd.com
viewport WIDTHxHEIGHT Sets the size of the virtual screen rendering the page. Default: smart width, full height viewport=1980x1080
js true|false Allows you to enable/disable JavaScript in the rendered Website. Default value: yes js=false

Examples

Simple link via img tag


<?php
    $url = 'http://www.xkcd.com';
    $query = 'viewport=1200x330&url='.rawurlencode($url);
    $img="https://http2pic.haschek.at/api/?$query";

    echo "<img src='$img' />";
                        

Proxy script to download the image via curl


<?php
    $targeturl = 'http://www.xkcd.com';
    $url = 'https://http2pic.haschek.at/api/?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);