Ecco qua! Finalmente! Ci sono riuscito. Mi sono messo un po' e ho risolto senza utilizzare global nè niente di quello che hai postato.
Questa è la funzione corretta.
Ora riesce a ridfimensionare il lato più lungo.
Un consiglio: prima di postare una risposta ad un quesito ripassa questi due passaggi:codice:class Image { var $src_filename; var $src_witdh; var $src_height; var $src_type; var $src_attr; var $src_image; var $side; 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 ($height , $width, $side) { if ($height > $width) { $this->side = $side; } elseif ($height == $width) { $this->side = $side; } elseif ($height < $width) { $this->side = ($height*$side)/$width; } } function SaveProportionateImage($filename, $quality, $height) { $this->GetHeight($this->src_height , $this->src_width , $height); $ratio = $this->src_height / $this->side; $dest_image = imagecreatetruecolor( $this->src_width / $ratio,$this->side); 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); } }
1) Capisci il problema
2) Vedi se lo conosci
Solo allora potrai postare. Se anche a un solo passaggio dai una risposta negativa non postare proprio! E' meglio per te e per chi tenta di trovare una soluzione o vuole un chiarimento. Ciao.![]()
![]()
![]()
![]()

Rispondi quotando