PHP GD to PHP cURL

I’ve read all stuff about cURL in wiki dreamhost and around google.

But anyone can help my doubt.
Please, somebody can help with this code below ?


define (“largura_max”, $_REQUEST[‘largura_max’]);

function open_url($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
$content = curl_exec ($curl);
curl_close ($curl);
return $content;
}

function dh_getimagesize($url) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
$img = imagecreatefromstring($result);

$imagesize[‘width’]= imagesx($img);
$imagesize[‘height’]= imagesy($img);

imagedestroy($img);

return $imagesize;
}

$DimensaoImg = dh_getimagesize ($_REQUEST[‘nome_arquivo’]);

$LarguraOriginal = $DimensaoImg[0];
$AlturaOriginal = $DimensaoImg[1];

//if ( $DimensaoImg [2] == 1 )
// $imgType = “gif”;
//elseif ( $DimensaoImg [2] == 2 )
$imgType = “jpeg”;
//elseif ( $DimensaoImg [2] == 3 )
// $imgType = “png”;

if ( $LarguraOriginal > largura_max ) {
$LarguraNova = largura_max;
$AlturaNova = ( largura_max * $AlturaOriginal ) / $LarguraOriginal;
} else {
$LarguraNova = $LarguraOriginal;
$AlturaNova = $AlturaOriginal;
}

header(“Content-type: image/” . $imgType);

$tImg = imagecreatetruecolor( $LarguraNova , $AlturaNova );
$imgOpenFunc = “imagecreatefrom”.$imgType;
$imgSendFunc = “image”.$imgType;

$img = $imgOpenFunc($_REQUEST[‘nome_arquivo’]);
imagecopyresampled( $tImg , $img , 0 , 0 , 0 , 0 , $LarguraNova , $AlturaNova , $LarguraOriginal , $AlturaOriginal );
imagedestroy($img);

$imgSendFunc($tImg);

Thank you!