Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Mi aiutate con questa classe?

    Salve. Ho trovato questa classe sul forum. Purtroppo permette solo di impostare l'altezza ma me serve che l'immagine generata stia in un quadrato di n lunghezza di lato. Ho preparato la funzione ed ho provato ad inserirla ma non funziona.
    Posto sia la funzione che ho creato che la classe modificata e la classe non modificata così potete avere tutto a disposizione:

    MIA FUNZIONE
    codice:
    function GetHeight ($height , $width, $side)
            {
               if ($height > $width)
                 {
                    return $side;
                 }
               elseif ($height < $width)
    		 {
    		    $side = ($height*$side)/$width;
    		    return $side;
    	         }
            }
    CLASSE MODIFICATA
    codice:
    class Image
         {
            var $src_filename;
            var $src_witdh;
            var $src_height;
            var $src_type;
            var $src_attr;
            var $src_image; 
    
            function Image($filename)
                    {
                       $this->src_filename = $filename;
                       $this->GetImageInfo();
                    }
    
            function GetImageInfo()
                    {
                       list($this->src_width,$this->src_height, $this->src_type, $this->src_attr) =  getimagesize($this->src_filename);
                    }
    
            function CreateSourceImage()
                    {
                       switch ($this->src_type)
                             {
                                case 1:
                                $this->src_image =imagecreatefromgif($this->src_filename);
                                break;
    
                                case 2:
                                $this->src_image =imagecreatefromjpeg($this->src_filename);
                                break;
    
                                case 3:
                                $this->src_image =imagecreatefrompng($this->src_filename);
                                break;
    
                                default: return false;
                             }
                       return true;
                    }
    
            function GetHeight ($side)
                    {
                       if ($this->src_height > $this->src_width)
                         {
                            return $height;
                         }
    		   elseif ($this->src_height < $this->src_width)
    		         {
    			    $height = ($this->src_height*$side)/$this->src_width;
    			    return $height;
    			 }
                    }
    		
    		function SaveProportionateImage($filename, $quality, $this->height)
                    {
                       $dest_height = $height;
                       $ratio = $this->src_height / $dest_height;
                       $dest_image = imagecreatetruecolor( $this->src_width / $ratio,$dest_height);
    
                       imagecopyresampled($dest_image, $this->src_image, 0, 0, 0, 0,$this->src_width / $ratio,$this->src_height / $ratio,$this->src_width,$this->src_height);
                       
                       imagejpeg($dest_image, $filename, $quality);
    
                       imagedestroy($dest_image);
                    }
    
            function Free()
                    {
                       imagedestroy($this->src_image);
                    }
         }
    CLASSE ORIGINALE
    codice:
    class Image
         {
            var $src_filename;
            var $src_witdh;
            var $src_height;
            var $src_type;
            var $src_attr;
            var $src_image; 
    
            function Image($filename)
                    {
                       $this->src_filename = $filename;
                       $this->GetImageInfo();
                    }
    
            function GetImageInfo()
                    {
                       list($this->src_width,$this->src_height, $this->src_type, $this->src_attr) =  getimagesize($this->src_filename);
                    }
    
            function CreateSourceImage()
                    {
                       switch ($this->src_type)
                             {
                                case 1:
                                $this->src_image =imagecreatefromgif($this->src_filename);
                                break;
    
                                case 2:
                                $this->src_image =imagecreatefromjpeg($this->src_filename);
                                break;
    
                                case 3:
                                $this->src_image =imagecreatefrompng($this->src_filename);
                                break;
    
                                default: return false;
                             }
                       return true;
                    }
    
            function SaveProportionateImage($filename, $quality, $height)
                    {
                       $dest_height = $height;
                       $ratio = $this->src_height / $dest_height;
                       $dest_image = imagecreatetruecolor( $this->src_width / $ratio,$dest_height);
    
                       imagecopyresampled($dest_image, $this->src_image, 0, 0, 0, 0,$this->src_width / $ratio,$this->src_height / $ratio,$this->src_width,$this->src_height);
                       
                       imagejpeg($dest_image, $filename, $quality);
    
                       imagedestroy($dest_image);
                    }
    
            function Free()
                    {
                       imagedestroy($this->src_image);
                    }
         }
    Spero che qualcuno mi possa aiutare perchè io non ci sto capendo più niente!

  2. #2
    Allora? Nessuno che mi sappia aiutare?

  3. #3
    ti ho risposto nella pillola... ma questo è crossposting? :master:

  4. #4
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    Originariamente inviato da andrea.paiola
    ti ho risposto nella pillola... ma questo è crossposting? :master:
    no, è crossposting postare la stessa richiesta su due forum diversi
    think simple think ringo

  5. #5
    Originariamente inviato da marketto
    no, è crossposting postare la stessa richiesta su due forum diversi
    allora questo lo chiamiamo crossthreading ?
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  6. #6
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    Originariamente inviato da andr3a
    allora questo lo chiamiamo crossthreading ?
    si



    meglio finire qua, altrimenti ci cazziano...
    think simple think ringo

  7. #7
    Avete ragione. Il fatto è che non trovavo il poste della pillola e quindi ho postato. Poi tra le vecchie mail mi sono ricordato di aver conserveto una notifica di risposta e quindi ho postato anche nella pillola.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.