- <?php  
- ob_start();  
- // Devuelve el identificador o false en caso de error  
- function imagecreatefromfile($imagefile)  
- {  
- // variable resultado  
-   
-     $resultado = false;  
-       
- // Obtener extensión del archivo   
-     $dot = (strlen($imagefile) - strrpos($imagefile, ".")-1)*(-1);  
-   
-     $ext = substr($imagefile, $dot);  
-     $ext = strtolower($ext);      
-           
- // Chequear que las imágenes sean de alguno de los formatos soportados. Por medio de la función strtolower(), pasamos la extensión a minúsculas  
-       
-     if( $ext == "gif") {  
-         if ($src_img = imagecreatefromgif($imagefile)) {  
-             $resultado = $src_img;  
-         }  
-     } else if( $ext == "jpg" || $ext == "jpeg") {  
-         if ($src_img = imagecreatefromjpeg($imagefile)) {  
-             $resultado = $src_img;  
-         }  
-     } else if( $ext == "png") {  
-         if ($src_img = imagecreatefrompng($imagefile)) {  
-             $resultado = $src_img;  
-         }  
-     } else if( $ext == "jpg" || $ext == "jpeg") {  
-         if ($src_img = imagecreatefromjpeg($imagefile)) {  
-             $resultado = $src_img;  
-         }  
-      }  
-       
-     return $resultado;              
- }  
-   
-   
- // genera una imagen thumbnail a partir de otra  
-   
- function generate_thumbnail($imagefile, $alto, $calidad = 100)  
- {  
- // leemos el fichero de la imagen  
-   
-     if( ($src_img = imagecreatefromfile($imagefile)) == false )  
-     {  
-         exit;  
-     }  
-     else  
-     {  
-         $hw = getimagesize($imagefile);  
-           
-     // $alto es el alto para la nueva imágen  
-         $new_w = $alto;  
-         //$hw[0]--> Ancho $hw[1]--> Alto   
-         //$new_h = $hw["0"]/($hw["1"]/$alto);//formula para todas las imagenes igual de altas  
-     $new_h=$hw[1]/($hw[0]/$alto); // formula para todas las imagenes igual de anchas  
-     // Intentamos crear una imágen 'true color'. Esta función es soportada a partir de GD 2.0, por lo que en caso de no funcionar, se usará la función imageCreate  
-   
-         $dst_img = @imagecreatetruecolor($new_w,$new_h);  
-         if(!$dst_img) {  
-           $dst_img = imageCreate($new_w,$new_h);  
-         }  
-           
-     // Se crea la imágen con los valores obtenidos y borramos las imágenes de la memoria  
-         imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));  
-         imagejpeg($dst_img,"", $calidad);  
-         ImageDestroy($src_img);  
-         ImageDestroy($dst_img);   
-     }  
- }  
- /////  
- require="conexion.php";  
- $reg = mysql_query("SELECT foto FROM blog WHERE id = ".$_GET['id_f']."")or die(mysql_error());  
-   
- $row = mysql_fetch_array($reg);  
- $file=$row['foto'];  
- //    header("Content-type: image/jpeg");  
- $imagen=generate_thumbnail($file, 75);//todas las imagenes son igual de anchas  
- echo $imagen;  
- ?>  
-