/*
Author: Blaz Grapar, blaz.grapar@email.si
20031030 Laurent G. Beaudet - Corrected the computation of height vs width
Please don't delete names in the script. Thanks.
This class creates a thumbnail of an image. Size of thumbnail is determined with maximum width and height of an thumbnail.
*/
// ==========================================================================================
// Changings:           by Gotti
// Purpose of changes:  If thumb with same size already exists we don't need to write it again.
//                      Support for GD1 added.
//                      GD does not support .gif so we handle them as .jpg
//                      Added missing function 'imagedestroy()'
// Changed lines:       135-146, 165-170, 199
// Homepage:            http://www.mambo.i-d-sign.com
// Author:              Gotti
// Date:                10.02.2004
// ==========================================================================================
class Thumbnail
        {
        var $source;
        var $max_width;
        var $max_height;
        var $dest;
        var $exist = false;
//        function Thumbnail( $source, $max_width = 100, $max_height = 100, $dest = '' )
        function Thumbnail( $source, $max_width, $max_height, $dest = '' )
                {
                $this->source = $source;
                $this->max_width = $max_width;
                $this->max_height = $max_height;
                $this->dest = $dest;
                
                }
        
        // Get the width of the original image
        function GetWidth()
                {
                $size = GetImageSize($this->source);
                return $size[0];
                //return ImageSX($this->source);
                }
        
        // Get the height of the original image
        function GetHeight()
                {
                $size = GetImageSize($this->source);
                return $size[1];
                //return ImageSY($this->source);
                }
        // Get the type of the image
        function GetType()
                {
                $size = GetImageSize($this->source);
                switch ( $size[2] )
                        {
                        case 1:
                                return 'gif';
                                break;
                        case 2:
                                return 'jpg';
                                break;
                        case 3:
                                return 'png';
                                break;
                        }
                }
        // Width calculation of thumbnail
        function CalcWidth()
                {
                if ($this->GetWidth() > $this->GetHeight()) {
                        //
                        // let's take the width as the largest dimension
                        //
                        return ($this->max_width);
                        } else {
                        //
                        // the width will have to be of the same ration as the height
                        //
                        return(floor(($this->max_height * $this->GetWidth()) / $this->GetHeight()));
                        }
                }
        // Height calculation of thumbnail
        function CalcHeight()
                {
                if ($this->GetWidth() > $this->GetHeight()) {
                        //
                        // the height will have to be of the same ration as the width
                        //
                        return(floor(($this->max_width * $this->GetHeight()) / $this->GetWidth()));
                        } else {
                        //
                        // let's take the height as the largest dimension
                        //
                        return($this->max_height);
                        }
                }
        // Creating a thumbnail
        function Create()
                {
                switch ($this->GetType())
                        {
                        case 'gif':
                                $img_src = ImageCreateFromGIF ( $this->source );
                                break;
                        case 'jpg':
                                $img_src = ImageCreateFromJPEG ( $this->source );
                                break;
                        case 'png':
                                $img_src = ImageCreateFromPNG ( $this->source );
                                break;
                        }
                $gd = 2;
                $img_des = ImageCreateTrueColor ( $this->CalcWidth(), $this->CalcHeight() );
                if (!$img_des) {
                        $gd = 1;
                        $img_des = ImageCreate( $this->CalcWidth(), $this->CalcHeight() );
                }
                for($i=0; $i<256; $i++)
                        imagecolorallocate($img_des, $i, $i, $i);
                        if ($gd==2) {
                                ImageCopyResampled( $img_des, $img_src, 0, 0, 0, 0, $this->CalcWidth(), $this->CalcHeight(), $this->GetWidth(), $this->GetHeight() );
                        } else {
                                imagecopyresized( $img_des, $img_src, 0, 0, 0, 0, $this->CalcWidth(), $this->CalcHeight(), $this->GetWidth(), $this->GetHeight() );
                        }
                return $img_des;
                }
        // Output the thumbnail to file or directly to a client
        function Output()
                {
                if (file_exists($this->dest)) {
                        $old_size = getimagesize($this->dest);
                        if ($old_size[0] == $this->CalcWidth())
                        $exist = true;
                }
                if ($exist==false) {
                switch ($this->GetType())
                        {
                        case 'gif':
                                if (empty($this->dest))
                                        {
                                        header ("Content-type: image/jpeg");
                                        return ImageJPEG($this->Create());
                                        }
                                else
                                        {
                                        return ImageJPEG( $this->Create(), $this->dest );
                                        }
                                break;
                        case 'jpg':
                                if (empty($this->dest))
                                        {
                                        header ("Content-type: image/jpeg");
                                        return ImageJPEG($this->Create());
                                        }
                                else
                                        {
                                        return ImageJPEG( $this->Create(), $this->dest );
                                        }
                                break;
                        case 'png':
                                if (empty($this->dest))
                                        {
                                        header ("Content-type: image/png");
                                        return ImagePNG($this->Create());
                                        }
                                else
                                        {
                                        return ImagePNG( $this->Create(), $this->dest );
                                        }
                                break;
                        }
                     imagedestroy($img_des);
                     }
                }
                
        }
?>
			 
			
		
				
			| 
			   La Gross Imball ha consolidato la posizione di leader nel settore del commercio di articoli ed attrezzature per l'imballaggio,e della produzione di buste e fogli in polietilene PE-FOAM, bolle aria, film estensibile e salvabordi PE L'importanza ed il successo ottenuti dalla società sono l'espressione della politica aziendale volta a soddisfare le diverse esigenze della clientela, sintetizzabili nei seguenti punti: - Qualità e diversificazione del prodotto. 
 - Celerità di acquisizione ed esecuzione dell'ordine mediante pronta consegna. 
 - Disponibilità immediata degli articoli richiesti, resa sempre possibile dalla capienza del proprio magazzino  e della razionale gestione delle scorte. 
 - Continua ricerca di nuovi prodotti e consulenza tecnica di utilizzo. 
 
 Il nostro CATALOGO on line vuole essere un piccolo grande "strumento  di lavoro" capace di assistervi ed aiutarvi a trovare, tra i nostri articoli la soluzione pi¨ giusta per l'imballo dei vostri prodotti.  Così il lavoro è protetto e il cliente è soddisfatto, molto soddisfatto.  Gross Imball Packaging solution srl 
 via dell' artigianato 22 33048 San Giovanni al Natisone UD
  telefono ( 0432-754988 )         fax ( 0432-754479 )
  p.iva 02320220417 			 | 
		 
				 
		
		 |   			 
		 | 
		
			  | 
		
    		
				
				
				
			
				
	  | 
	  | 
	>> | 
 
			 | 
		 
		 
		 | 
		
			  |