Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/07/2007, 18:59
GPS
 
Fecha de Ingreso: diciembre-2003
Ubicación: Montevideo, Uruguay
Mensajes: 110
Antigüedad: 20 años, 4 meses
Puntos: 0
Re: crear thumbnails y guardarlos en mysql

No se como guardar una imagen en una bd (ni tampo se si se puede) pero lo que si puedes hacer, y creo es la mejor opción, es guardar los thum en una carpeta, y luego guardar el nombre del mismo en la bd.

En cuanto al script para crear los thumbnails aqui te dejo uno

Código PHP:
function crea_thumb($imagen$tamano$destino) { 
    
$info getImageSize($imagen$info); 

    
$old_x $info[0]; 
    
$old_y $info[1]; 

    
$new_w = (int)($tamano); 
    if ((
$new_w <= 0) || ($new_w $old_x)) 
        
$new_w $old_x

    
$new_h = ($old_x * ($new_w $old_x)); 
    if (
$old_x $old_y) { 
        
$thumb_w $new_w
        
$thumb_h $old_y * ($new_h $old_x); 
    } 

    if (
$old_x $old_y) { 
        
$thumb_w $old_x * ($new_w $old_y); 
        
$thumb_h $new_h
    } 
    if (
$old_x == $old_y) { 
        
$thumb_w $new_w
        
$thumb_h $new_h
    } 


    
$im imageCreateFromJPEG($imagen); 

    
$orange imageColorAllocate($im22021060); 
    
$thumb ImageCreateTrueColor($thumb_w$thumb_h); 
    
imageCopyResized($thumb$im0000$thumb_w$thumb_h$old_x$old_y); 

    
imageJPEG($thumb$destino70); 

    
imageDestroy($thumb);