query("SELECT * FROM imagens where id_user='$id' and arquivo='$img'"); $mostra = $localiza->fetch(); $data = $mostra["conteudo"]; $type = $mostra["tipo"]; Header( "Content-type: $type"); if ($forum == "1") { $size = 120; // new image width } else { $size = 80; // new image width } $src = imagecreatefromstring($data); $width = imagesx($src); $height = imagesy($src); $aspect_ratio = $height/$width; if ($width <= $size) { $new_w = $width; $new_h = $height; } else { $new_w = $size; $new_h = abs($new_w * $aspect_ratio); } $img = imagecreatetruecolor($new_w,$new_h); imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height); // determine image type and send it to the client if ($type == "image/jpeg") { imagejpeg($img, null, 90); } else if ($type == "image/png") { imagepng($img, null, 9); } else if ($type == "image/gif") { imagegif($img, null, 90); } imagedestroy($img); } // fim funcao gera_foto($_GET['id'],$_GET['img'],$_GET['forum'],$mySQL); ?>