<?PHP define(MAX_WIDTH, 100); define(MAX_HEIGHT, 100); $image_file = "http://www.teste.com/papeis_de_parede/maiden.jpg"; $image_path = $image_file; $img = null; $extensao = strtolower(end(explode('.', $image_path))); if ($extensao == 'jpg' || $extensao == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($extensao == 'png') { $img = @imagecreatefrompng($image_path); } else if ($extensao == 'gif') { $img = @imagecreatefromgif($image_path); } if ($img) { $width = imagesx($img); $height = imagesy($img); $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height); if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } if (!$img) { $img = imagecreate(MAX_WIDTH, MAX_HEIGHT); imagecolorallocate($img,255,255,255); $c = imagecolorallocate($img,153,153,153); $c1 = imagecolorallocate($img,0,0,0); imagestring($img, 2, 40, 25, 'ERRO',$c1 ); imagestring($img, 2, 45, 45, 'ERRO',$c1 ); imagestring($img, 2, 40, 65, 'ERRO',$c1 ); } header('Content-type: image/jpeg'); imagejpeg($img); ?>
Edição feita por: Agência-vr, 01/02/2005, 01:48.