Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/04/2008, 14:18
LeandroA
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 21 años, 6 meses
Puntos: 3
imageCreateFromJPEG no soporta imagenes pesadas

buenas estoy utilizando una funcion para hacer un Thumbnail pero cuando le paso imagenes grandes no me funciona por ejemplo una imagen con un peso de 1.567.015 bytes (1,49 MB) la funcion es esta
Código PHP:
<?php

function makeThumbnail($file, $t_ht = 100) {
    
$image_info = getImageSize($file) ; // see EXIF for faster way

    
switch ($image_info['mime']) {
        case 
'image/gif':
            if (
imagetypes() & IMG_GIF)  { // not the same as IMAGETYPE
                
$o_im = imageCreateFromGIF($file) ;
            } else {
                
$ermsg = 'GIF images are not supported<br />';
            }
            break;
        case 
'image/jpeg':
            if (
imagetypes() & IMG_JPG)  {
                
$o_im = imageCreateFromJPEG($file) ;
            } else {
                
$ermsg = 'JPEG images are not supported<br />';
            }
            break;
        case 
'image/png':
            if (
imagetypes() & IMG_PNG)  {
                
$o_im = imageCreateFromPNG($file) ;
            } else {
                
$ermsg = 'PNG images are not supported<br />';
            }
            break;
        case 
'image/wbmp':
            if (
imagetypes() & IMG_WBMP)  {
                
$o_im = imageCreateFromWBMP($file) ;
            } else {
                
$ermsg = 'WBMP images are not supported<br />';
            }
            break;
        default:
            
$ermsg = $image_info['mime'].' images are not supported<br />';
            break;
    }

    if (!isset(
$ermsg)) {
        
$o_wd = imagesx($o_im) ;
        
$o_ht = imagesy($o_im) ;
        
// thumbnail width = target * original width / original height
        
$t_wd = round($o_wd * $t_ht / $o_ht) ;

        
$t_im = imageCreateTrueColor($t_wd,$t_ht);

        
imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);

        
imageJPEG($t_im);

        
imageDestroy($o_im);
        
imageDestroy($t_im);
    }
    return isset(
$ermsg)?$ermsg:NULL;
}

header("Content-type: image/jpeg");
makeThumbnail($_GET['imagename'], 150);

?>
alguien sabe como puedo solucionarlo o que forma reducir las imagenes en el servidor (creo que este metodo le dicen "al vuelo") para mostrarlas en miniatura.

Saludos