Get size of redirected image from remote url

htdesignz

Active member
Do XF supports to get image size of redirected image from remote url?
I have tried with Curl, but it got a empty image.

PHP:
$file = 'http://i2.minus.com/jpWyJdpK4Kd1M.png';
 
function save_image($img, $fullpath){
    $ch = curl_init ($img);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    $rawdata=curl_exec($ch);
    curl_close ($ch);
    if(file_exists($fullpath)){
        unlink($fullpath);
    }
    $fp = fopen($fullpath,'x');
    fwrite($fp, $rawdata);
    fclose($fp);
}
 
save_image($file, __DIR__ . '/image.png');
 
Top Bottom