Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/02/2007, 15:01
Avatar de oso96_2000
oso96_2000
 
Fecha de Ingreso: junio-2002
Ubicación: Distrito Federal
Mensajes: 558
Antigüedad: 22 años, 7 meses
Puntos: 35
Re: manejo de fotos con php

Código PHP:
function thumb($img$w$h$fill true) {
    if (!
extension_loaded('gd') && !extension_loaded('gd2')) {
        
trigger_error("No dispones de la libreria GD para generar la imagen."E_USER_WARNING);
        return 
false;
    }

    
//$ext = strtolower(array_pop(explode(".",$img)));
    
$imgInfo getimagesize($img);
    switch (
$imgInfo[2]) {
        case 
1$im imagecreatefromgif($img); break;
        case 
2$im imagecreatefromjpeg($img);  break;
        case 
3$im imagecreatefrompng($img); break;
        default:  
trigger_error('Tipo de imagen no reconocido.'E_USER_WARNING);  break;
    }

    if (
$imgInfo[0] <= $w && $imgInfo[1] <= $h && !$fill) {
        
$nHeight $imgInfo[1];
        
$nWidth $imgInfo[0];
    }else{
        if (
$w/$imgInfo[0] < $h/$imgInfo[1]) {
            
$nWidth $w;
            
$nHeight $imgInfo[1]*($w/$imgInfo[0]);
        }else{
            
$nWidth $imgInfo[0]*($h/$imgInfo[1]);
            
$nHeight $h;
        }
    }
  
    
$nWidth round($nWidth);
    
$nHeight round($nHeight);

    
$newImg imagecreatetruecolor($nWidth$nHeight);

    
imagecopyresampled($newImg$im0000$nWidth$nHeight$imgInfo[0], $imgInfo[1]);

    
header("Content-type: "$imgInfo['mime']);

    switch (
$imgInfo[2]) {
        case 
1imagegif($newImg); break;
        case 
2imagejpeg($newImg);  break;
        case 
3imagepng($newImg); break;
        default:  
trigger_error('Imposible mostrar la imagen.'E_USER_WARNING);  break;
    }
  
    
imagedestroy($newImg);

Una funcion que sirve para mostrar una imagen redimencionada..

<?php thumb("imagen.jpg", 200, 200); ?>

Eso deberia estar en una pagina sin nada mas, mostraria una redimension de imagen.jpg con un maximo de 200 pixeles de ancho o alto..

Es una idea de como podrias redimensionar la tuya =)
__________________
Sin Ideas