Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/02/2011, 18:16
urielisho
 
Fecha de Ingreso: noviembre-2007
Mensajes: 12
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Manipulación de imágenes con PHP

Hola amigos e estado trabajando en esto un par de días y nada mas no puedo hacer que la imagen que envío, se reduzca con imagecopyresampled().

Les agrego el código de la función que utilizo:

Código PHP:
function resizeImage($originalImage,$toWidth,$toHeight

    
    
$info    =    getimagesize($originalImage);
    
$width    =    $info[0];
    
$height    =    $info[1];
    
$type    =    image_type_to_mime_type($info[2]);
    
$interlace    =    true;
    
    if( 
$width >= $height )
        
$width    =    $height;
    else
        
$height    =    $width;
    
    
//Percentage Change
    
$newWidth    =    ( 20 100 ) * $width;
    
$newHeight    =    ( 20 100 ) * $height;
    
    
//Width change
    
$newWidth    =    89;
    
$newHeight    =    ( $height $newWidth ) / $width;
    
    
//Height change
    
$newHeight    =    67;
    
$newWidth    =    ( $width $newHeight ) / $height;
    
    
$newImage    =    imagecreatetruecolor$newWidth $newHeight );
    
imageinterlace$newImage $interlace );
    
$image imagecreatefromjpeg($originalImage);
    
    
imagecopyresampled($newImage ,$image $newWidth $newHeight $width $height );
    
    
    switch(
$type)
    {
        case 
'image/jpeg':
            
imagejpeg($newImage ,$image,100);
            break;
        case 
'image/gif':
            
imagegif($newImage ,$image,100);
            break;
        case 
'image/png':
            
imagepng($newImage ,$image100 );
            break;
    }
    return 
$newImage;

y el código de donde quiero recuperar la imagen:

Código PHP:

...mas codigo...
    
$image resizeImage($b['Photos']['Photo_attr']['src'],89,67);
                            
//print_r($image);
                            
$imagen '<img src="'.get_template_directory_uri() . '/'.$image.'" align="left" border="none" />';
                    
...
mas codigo... 
Pero no me devuelve nada e incluso me imprime caracteres extraños...

Les agradesco de antemano su ayuda.

Saludos