Ver Mensaje Individual
  #10 (permalink)  
Antiguo 16/05/2007, 14:48
jonyjm
 
Fecha de Ingreso: mayo-2005
Mensajes: 94
Antigüedad: 18 años, 11 meses
Puntos: 0
Re: Condicionar tamaño de imagen

no me va.. jaja, no me entero de nada... mira, estoy llamando a este include... con la funcion...

Código PHP:
<?php

function img_resize($path,$w=0,$h=0,$quality=100,$save=''){

  
$image_data=@getimagesize($path);

  
$image_type=$image_data[2];
  
$gd_ext=array('','jpg','gif');
  if(
$image_type!=1&&$image_type!=2) return false;
  if(
$save==''header('Content-type: '.$image_data['mime']); else $save=eregi_replace('%ext',$gd_ext[$image_type],$save);

  if(
$w!=0){
   
$rapporto=$image_data[0]/$w;
   if(
$h!=0){
     if(
$image_data[1]/$rapporto>$h$rapporto=$image_data[1]/$h;
   }
  }elseif(
$h!=0){
   
$tmp_h=$image_data[1]/$h;
  }else{
   return 
false;
  }

  
$thumb_w=$image_data[0]/$rapporto;
  
$thumb_h=$image_data[1]/$rapporto;

  if(
$image_type==1$img_src=@imagecreatefromgif($path);
  elseif(
$image_type==2$img_src=@imagecreatefromjpeg($path);

  
$img_thumb=@imagecreatetruecolor($thumb_w,$thumb_h);
  
$result=@imagecopyresampled($img_thumb,$img_src,
0,0,0,0,$thumb_w,$thumb_h,$image_data[0],$image_data[1]);
  if(!
$img_src||!$img_thumb||!$result) return false;

  if(
$image_type==1$result=@imagegif($img_thumb,$save);
  elseif(
$image_type==2$result=@imagejpeg($img_thumb,$save,$quality);

  return 
$result;
}
?>
pero no lo entiendo.. como usarlo para guardar la imagen sin redimencionar...

Saludos, gracias