Example #1
0
function camera_image_size($url, $size = '')
{
    $start = microtime(true);
    $raw = ranger($url);
    $im = @imagecreatefromstring($raw);
    $width = imagesx($im);
    $height = imagesy($im);
    $stop = round(microtime(true) - $start, 5);
    if ($size == 'width') {
        return $width;
    } elseif ($size == 'height') {
        return $height;
    } else {
        echo 'width=' . $width . 'px; height=' . $height . 'px';
    }
}
Example #2
0
{
    $headers = ['User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12', 'Range: bytes=0-32768'];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $data = curl_exec($curl);
    curl_close($curl);
    return $data;
}
if (!isset($_GET['url'])) {
    http_response_code(400);
    return;
}
$url = $_GET['url'];
$raw = ranger($url);
if (!($im = imagecreatefromstring($raw))) {
    http_response_code(400);
    return;
}
$width = imagesx($im);
$height = imagesy($im);
if ($width && $height) {
    http_response_code(200);
    echo json_encode(['url' => $url]);
    return;
}
http_response_code(400);