Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/09/2009, 18:00
Avatar de chulifo
chulifo
 
Fecha de Ingreso: abril-2009
Ubicación: perdido en codigos del PHP, pero aprendo rapido!
Mensajes: 524
Antigüedad: 15 años, 9 meses
Puntos: 18
Respuesta: como reducir imagenes

espero q esto te sirva
edito:
Código php:
Ver original
  1. <?php
  2.  
  3. $anchura=250;
  4. //hay un maximo de 70:S asi que un numero superior no sirve
  5. $hmax=70;
  6. //direccion de tu imagen base
  7. $nombre='imagenes/barner.png';
  8. $datos = getimagesize($nombre);
  9. if($datos[2]==1){$img = @imagecreatefromgif($nombre);}
  10. if($datos[2]==2){$img = @imagecreatefromjpeg($nombre);}
  11. if($datos[2]==3){$img = @imagecreatefrompng($nombre);}
  12. $ratio = ($datos[0] / $anchura);
  13. $altura = ($datos[1] / $ratio);
  14. if($altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;}
  15. $thumb = imagecreatetruecolor($anchura,$altura);
  16. imagecopyresampled($thumb, $img, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]);
  17. if($datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);}
  18. if($datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);}
  19. if($datos[2]==3){header("Content-type: image/png");imagepng($thumb); }
  20. imagedestroy($thumb);
  21. ?>
__________________
Solo soy un simple fanático que mata el tiempo de la mejor manera.