Página resize.php
Código PHP:
   <?php 
// Useage: thumbnail.php?im=image.jpg
// Optional: thumbnail.php?im=image.jpg&maxsize=100
$im      = $_GET['im'];
$maxsize = $_GET['maxsize'];
if (strpos($im,"gif")==false){
 
 
            
if ($maxsize == '') {
    $maxsize = 100;
}
 
// The file
$filename = $im;
 
// Set a maximum height and width
$width  = $maxsize;
$height = $maxsize;
 
// Content type
header('Content-type: image/jpeg');
 
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
 
if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
} else {
    $height = ($width / $width_orig) * $height_orig;
}
 
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image   = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 
// Output
imagejpeg($image_p);
imagedestroy($image);
imageDestroy($image_p);
 
}
//------------------------------------------------------------------   gif
else
{
 
 
 
 
            
if ($maxsize == '') {
    $maxsize = 100;
}
 
// The file
$filename = $im;
 
// Set a maximum height and width
$width  = $maxsize;
$height = $maxsize;
 
// Content type
  Header("Content-type: image/gif"); 
 
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
 
if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
} else {
    $height = ($width / $width_orig) * $height_orig;
}
 
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image   = imagecreatefromgif($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 
// Output
 imageGif($image_p);
imagedestroy($image);
imageDestroy($image_p);
$fuente = @imagecreatefromgif($im);
           
    
       
}
?>    
Código:
  
Bueno no se si a alguien le servirá pero aki os la dejo, la verdad es que no he probado con png, seguiro que hay cientos de scripts como este pero bueno, yo dejo aki mi aportación.<img src="resize.php?im=images/vehiculo34/05.jpg&maxsize=188">
Chau y que la fuerza os acompañe!!! jejej
 
 

 )
 ) 
 
 Este tema le ha gustado a 1 personas
Este tema le ha gustado a 1 personas