Foros del Web » Programando para Internet » PHP »

Importar imagenes mediante CRON

Estas en el tema de Importar imagenes mediante CRON en el foro de PHP en Foros del Web. Hola a todos! Os voy a contar mi problema haber si me podeis ayudar a solucionarle. Tengo en un servidor dos páginas webs, la una ...
  #1 (permalink)  
Antiguo 16/02/2012, 14:59
 
Fecha de Ingreso: abril-2003
Mensajes: 363
Antigüedad: 21 años
Puntos: 3
Importar imagenes mediante CRON

Hola a todos!

Os voy a contar mi problema haber si me podeis ayudar a solucionarle.
Tengo en un servidor dos páginas webs, la una es la que alberga las imágenes y la otra es la que las muestra al público.
Tengo un script que las redimensiona mediante CRON (ya que no las puedo coger directamente y redimensionarlas)
El código del script es:
Código PHP:
/*
    Con CURL obtenemos la imagen de otro alojamiento
*/

$ch curl_init();
curl_setopt($chCURLOPT_URL$_GET['imagen']);
curl_setopt($chCURLOPT_HEADERfalse);
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
$resultado curl_exec($ch);
$error curl_error($ch);
curl_close($ch);


// Image Resize Script by Zipline Interactive
// http://www.gozipline.com
// http://www.gozipline.com/42,phpimageresizefunction
// [email protected]
// 02/02/2008

// This will resize an image keeping its height/width aspect ratio if you do not specify a height value.

// USAGE:

    // MAINTAIN ASPECT AND SAVE FILE.
    // This will create a new files called 'resizedImage.jpg' with a longest side resized to 600px.
    // resizeImage('../uploads/uploadedImage.jpg','resizedImage.jpg','600'); 
    
    // MATIAN ASPECT AND SHOW THE IMAGE IN THE BROWSER.
    // No other output can be shown before this image.
    // resizeImage('../images/uploadedImage.jpg','','450');
    
    // RESHAPE IMAGE WITH SET SIZES
    // This will reshape the image to the set dimensions and save as a jpg file.
    // resizeImage('uploadedImage.jpg','../images/resized/resizedImage.jpg','150','150');

function resizeImage($data$destination NULL$wdt$height NULL){
    if(empty(
$height)){
        
$image imagecreatefromstring($data);
        
        
// Height is nit set so we are keeping the same aspect ratio.
        
$width imagesx($image);
        
$height imagesy($image);

        if(
$width $height){
            
$w $wdt;
            
$h = ($height $width) * $w;
            
$w $w;
        }else{
            
$w $wdt;
            
$h $w;
            
$w = ($width $height) * $w;
        }
    }else{
        
// Both width and Height are set.
        // this will reshape to the new sizes.
        
$w $wdt;
        
$h $height;
    }
    
$source_image = @imagecreatefromstring($data) or die('No es una imagen valida');
    
$sw imagesx($source_image);
    
$sh imagesy($source_image);
    
$ar $sw/$sh;
    
$tar $w/$h;
    if(
$ar >= $tar){
        
$x1 round(($sw - ($sw * ($tar/$ar)))/2);
        
$x2 round($sw * ($tar/$ar));
        
$y1 0;
        
$y2 $sh;
    }else{
        
$x1 0;
        
$y1 0;
        
$x2 $sw;
        
$y2 round($sw/$tar);
    }
    
$slate = @imagecreatetruecolor($w$h) or die('Dimensiones de la miniatura incorrectas');
    
imagecopyresampled($slate$source_image00$x1$y1$w$h$x2$y2);
    
// If $destination is not set this will output the raw image to the browser and not save the file
    
if(!$destinationheader('Content-type: image/jpeg');
    @
imagejpeg($slate$destination100) or die('Problema con los permisos del directorio');
    
ImageDestroy($slate);
    
ImageDestroy($source_image);
    if(!
$destination) exit;
    return 
true;
}

 
//Redimensionamos la imagen
 
resizeImage($resultado,'',$_GET['dimensiones']); 
Aqui le paso la ruta de la imagen (de la forma http://www.dominio.com/foto.jpg) y las dimensiones máximas, funciona correctamente, el problema es que aunque está al 100% de calidad la imagen redimensionada no se ve con calidad, se nota muchisimo la diferencia.
No se si es porque se coge mediante http, ¿conoceis algún script o sabeis como puedo hacer para cogerla por la ruta del servidor (p.ej. /ruta/de/la/carpeta/a/explorar/foto.jpg)?
¿O sabeis porque puede notarse tanto la diferencia?

Muchisimas Gracias
  #2 (permalink)  
Antiguo 17/02/2012, 00:34
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Importar imagenes mediante CRON

aunque está al 100% de calidad la imagen redimensionada no se ve con calidad, se nota muchísimo la diferencia. que es "calidad"? Será "resolución"??. Asegúrate que estás mostrando la imagen con el tamaño exacto que tienen, si en tamaño real se ven bien, entonces tu problema es otro.
__________________
Fere libenter homines, id quod volunt, credunt.
  #3 (permalink)  
Antiguo 17/02/2012, 03:50
 
Fecha de Ingreso: abril-2003
Mensajes: 363
Antigüedad: 21 años
Puntos: 3
Respuesta: Importar imagenes mediante CRON

en realidad este script la redimensiona al tamaño que le pasemos, además si ponemos el tamaño total también se ve peor que el original.
¿porque puede ser?
  #4 (permalink)  
Antiguo 17/02/2012, 04:15
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Importar imagenes mediante CRON

Empieza a mirar por aquí:

Código PHP:
Ver original
  1. imagecopyresampled($slate, $source_image, 0, 0, $x1, $y1, $w, $h, $x2, $y2);


http://de.php.net/manual/es/function...yresampled.php
__________________
Fere libenter homines, id quod volunt, credunt.

Etiquetas: cron, imagenes, mediante
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:14.