Ciao a tutti!
ho un problemino! ho uno script che mi permette di creare un'immagine con un logo sopra (watermark) ma ho un problema.

con un file PNG lo sfondo del wm diventa bianco, invece di lasciarlo trasparente.
con una GIF, le sfumature del wm non vengono trasferite nella trasformazione da PNG a GIF.

lo script è:

Codice PHP:
class img 
{    
    var 
$thumb_w =640// larghezza thumb
    
var $thumb_h =480// altezza thumb
    
var $max_w 720// larghezza max
    
var $max_h 540// altezza max
    
var $pos_x "CENTER"// posizione logo
    
var $pos_y "MIDDLE"// posizione logo
    
var $img_folder ""// cartella immagine grande
    
var $thumb_folder ""// cartella immagine thumb
    
var $saveBIG 1//salvare immagine grande
    
var $saveTHUMB 0//salvare thumb
    
var $name ""//nome immagine senza estensione

    
function AddLogo($image$logo NULL)
    {
        
$this->im $this->createImgage($image);
        
$this->im_width imagesx($this->im);
        
$this->im_height imagesy($this->im);
        
$this->wt_x $this->calc_pos_x($this->pos_x);
        
$this->wt_y $this->calc_pos_y($this->pos_y);
        
        
$this->new_image $this->resizeImg();
        
$this->resizeForThumb();
        
        if(
$logo != NULL)
        {
            
$this->createTheLogo($logo);                
        }
        if(
$this->name==""){
            
$this->name substr($imagestrrpos($image"."));
        }
        if(
$this->saveBIG == 1)
        {
            
imagejpeg($this->new_image$this->img_folder.$this->name."_logo.jpg");
        }
        if(
$this->saveTHUMB == 1)
        {
            
imagejpeg($this->thumb$this->thumb_folder.$this->name."_small.jpg");
        }
        
    }
    
    function 
createImgage($image){
        
$type strtolower(substr($imagestrrpos($image"."), strlen($image)-strrpos($image".")));
        if(
$type==".jpeg" || $type==".jpg"){
            return 
imagecreatefromjpeg($image);
        }elseif(
$type==".gif"){
            return 
imagecreatefromgif($image);
        }elseif(
$type==".png"){
            return 
imagecreatefrompng($image);
        }else{
            die(
"Immagine non valida");
        }
    }
    
    function 
createTheLogo($logo)
    {
        
$this->logo $this->createImgage($logo);
        
$this->logo_width imagesx($this->logo);
        
$this->logo_height imagesy($this->logo);
        
$this->wt_x $this->calc_pos_x($this->pos_x);
        
$this->wt_y $this->calc_pos_y($this->pos_y);
        
imagecopymerge($this->new_image$this->logo$this->wt_x$this->wt_y00$this->logo_width$this->logo_height100);
    }
        
        
    function 
resizeImg()
    {

        if(
$this->im_width $this->max_w && $this->im_height $this->max_h)
        {
        
            
$rapporto $this->max_w $this->im_width;
            
            
$this->new_im_w $this->im_width $rapporto;
            
$this->new_im_h $this->im_height $rapporto;
            
        }
        
        else if(
$this->im_width $this->max_w && $this->im_height $this->max_h)
        {
        
            
$rapporto $this->max_h $this->im_height;
            
            
$this->new_im_w $this->im_width $rapporto;
            
$this->new_im_h $this->im_height $rapporto;
        
        }
        else if(
$this->im_width $this->max_w && $this->im_height $this->max_h)
        {
        
            
$rapporto_1 $this->max_w $this->im_width;
            
$rapporto_2 $this->max_h $this->im_height;
                if(
$rapporto_1 $rapporto_2)
                {
                    
$rapporto $rapporto_2;
                }
                else
                {
                    
$rapporto $rapporto_1;
                }
                    
                    
$this->new_im_w $this->im_width $rapporto;
                    
$this->new_im_h $this->im_height $rapporto;
        
        }
        
        else
        {
            
$this->new_im_w $this->im_width;
            
$this->new_im_h $this->im_height;
        }
        
        
$this->new_image imagecreatetruecolor($this->new_im_w$this->new_im_h);
        
imagecopyresized($this->new_image$this->im0000$this->new_im_w$this->new_im_h$this->im_width$this->im_height);
        
        return 
$this->new_image;

    }
        function 
resizeForThumb()
        {
            
$thumb_w $this->thumb_w;
            
$thumb_h $this->thumb_h;
            if(
$this->im_width $this->im_height)
            {
                
$rapporto $this->im_height $this->im_width;
                
$thumb_h $this->thumb_w $rapporto;
            }    
            else if(
$this->im_width $this->im_height)
            {
                
$rapporto $this->im_width $this->im_height;
                
$thumb_w $this->thumb_h $rapporto;
            }
            else
            {
                
$thumb_w $this->thumb_w;
                
$thumb_h $this->thumb_h;
            }
            
$this->thumb imagecreatetruecolor($thumb_w$thumb_h);
            
imagecopyresized($this->thumb$this->new_image0000$thumb_w$thumb_h$this->new_im_w$this->new_im_h);

        }
        
    function 
calc_pos_x($position_x)
        {
        
$x 0;
        switch(
$position_x)
        {
            case 
'LEFT':
                
$x 0;
                break;
            case 
'CENTER':
                
$x = @$this->new_im_w - @$this->logo_width 2;
                break;
            case 
'RIGHT':
                
$x = @$this->new_im_w - @$this->logo_width;
                break;
            default:
                
$x 0;
        }
            return 
$x;
        
        }
        
        function 
calc_pos_y($position_y)
        {
        
$y 0;
        switch(
$position_y)
        {
            case 
'TOP':
                
$y 0;
                break;
            case 
'MIDDLE':
                
$y = @$this->new_im_h - @$this->logo_height 2;
                break;
            case 
'BOTTOM':
                
$y = @$this->new_im_h - @$this->logo_height;
                break;
            default:
                
$y 0;
        }
    return 
$y;
        
        }
        
}
    
?> 
nella mia pagina, chiamo la funzione Addlogo().
é possibile far "leggere" allo script un PNG giusto? oppure, è possibile convertire una GIF esattamente?

grazie a tutti, spero di essermi spiegato!

SImo