Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2004, 09:26
Avatar de gildus
gildus
 
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 23 años, 2 meses
Puntos: 105
Imagenes Distorsionads

Hola amigos, , tengo un problemilla, , No puedo mostrar bien una imagen a la que cambio de tamaño, lo cambia de tamaño pero no se muestran bien algunas o casi la mayoria de las fotos, solo unas cuantas puedes mostrarse bien pero con algunas o pequeñas deformaciones, .

Como puedo cabiar el tamaño si que afecte la calidad de la imagen. Algunas veces la cambia de color medio rojizo otras azules, y no se porque, . Manejo imagenes .JPG y utilizo un servicio de hosting que tiene compilado todas las librerias GD jpg, gif, png. y no entiendo porque. Utilizo este script para cambiar el tamaño de las imagenes:


Código PHP:
<?php
$image 
= $HTTP_GET_VARS['image']; //nombre de la imagen
$type = $HTTP_GET_VARS['type']; // para el tamaño de la figura, pues las
//utilizo para distintos cambios de tamaño.

switch($type)
{    case 
1: if (!$max_width)      $max_width = 250;
            if (!
$max_height)      $max_height = 230;
            break;
    case 
2:    if (!$max_width)      $max_width = 200;
            if (!
$max_height)      $max_height = 180;    
            break;
    case 
3:    if (!$max_width)      $max_width = 200;
            if (!
$max_height)      $max_height = 180;    
            break;
}

$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];

$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( (
$width <= $max_width) && ($height <= $max_height) ) 
{    
  
$tn_width = $width;
  
$tn_height = $height;
}
else 
{    if ((
$x_ratio * $height) < $max_height) 
    {
      
$tn_height = ceil($x_ratio * $height);
      
$tn_width = $max_width;
    }
    else 
    {
      
$tn_width = ceil($y_ratio * $width);
      
$tn_height = $max_height;
    }
}
$src = imagecreatefromjpeg($image);
if (!
$src) { /* Comprobar si ha fallado */
        
$src  = imagecreate (150, 30); /* Crear una imagen en blanco */
        
$bgc = imagecolorallocate ($src, 255, 255, 255);
        
$tc  = imagecolorallocate ($src, 0, 0, 0);
        
imagefilledrectangle ($src, 0, 0, 150, 30, $bgc);
        
/* Mostrar un mensaje de error */
        
imagestring ($src, 1, 5, 5, "Error cargando $nombreimg", $tc);
   }


$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,$tn_width,$tn_height,$width,$height);
header('Content-type: image/jpeg');
$r = imagejpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);

?>

Si alguien tiene alguna sugerencia para este problemilla, se los agradecere de antemano. .

Saludos,

Gildus
__________________
.: Gildus :.