Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/12/2010, 11:28
walterdevel
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 5 meses
Puntos: 51
Respuesta: Redimensionar imagen al subirla al servidor

Te paso una función php para cortar la imagen:

Código PHP:
function cut_image($src_img$dst_img$dst_width$dst_height,$x$y) {
    
$result false;

    if (
file_exists ($src_img)) {
        list(
$width$height$type) = getimagesize($src_img);

        
$image_tmp imagecreatetruecolor($dst_width$dst_height);
        if (
$type == 1) {
            
$source imagecreatefromgif($src_img);
        }  elseif (
$type == 2) {
            
$source imagecreatefromjpeg($src_img);
        }  elseif (
$type == 3) {
            
$source imagecreatefrompng($src_img);
        }

        
imagecopy($image_tmp$source00$x$y $dst_height$dst_width$dst_height);

        if (
$dst_height 78 && $dst_width 78){
            
$image_tmp2 $image_tmp;
            
$image_tmp imagecreatetruecolor(7878);
            
imagecopyresampled($image_tmp$image_tmp200007878$dst_width$dst_height);
        }

        
$result imagejpeg($image_tmp$dst_img);
    }

    return 
$result;