Ciao a tutti,
sto usando un piccolo CMS per annunci ed ho un piccolo problema.

Quando vado a fare l'upload delle immagini lui mi ricrea le thumbnail del valore che gli scrivo io (150x200) ma il problema è che mi ridimensiona l'immagine e mi crea una cornice bianca attorno ad essa ottenendo in totale le dimensioni di 150x200 mentre io avrei bisogno di avere l'immagine intera a 150x200 senza la cornice, in allegato il file resizer.php:

codice:
    class ImageResizer {

        public static function fromFile($imagePath) {
            return new ImageResizer($imagePath);
        }

        private $im;

        private function __construct($imagePath) {
            if(!file_exists($imagePath)) throw new Exception("$imagePath does not exist!");
            if(!is_readable($imagePath)) throw new Exception("$imagePath is not readable!");

            $content = file_get_contents($imagePath);
            $this->im = imagecreatefromstring($content);

            return $this;
        }

        public function __destruct() {
            imagedestroy($this->im);
        }

        public function resizeToMax($size) {
            $w = imagesx($this->im);
            $h = imagesy($this->im);

            if($w >= $h) {
                //$newW = $size;
                $newW = ($w > $size)? $size : $w;
                $newH = $h * ($newW / $w);
            } else {
                //$newH = $size;
                $newH = ($h > $size)? $size : $h;
                $newW = $w * ($newH / $h);
            }

            $newIm = imagecreatetruecolor($newW, $newH);
            imagealphablending($newIm, false);
            $colorTransparent = imagecolorallocatealpha($newIm, 255, 255, 255, 127);
            imagefill($newIm, 0, 0, $colorTransparent);
            imagesavealpha($newIm, true);
            imagecopyresized($newIm, $this->im, 0, 0, 0, 0, $newW, $newH, $w, $h);
            imagedestroy($this->im);

            $this->im = $newIm;

            return $this;
        }

        public function resizeTo($width, $height) {
            $w = imagesx($this->im);
            $h = imagesy($this->im);

            if(($w/$h)>=($width/$height)) {
                //$newW = $width;
                $newW = ($w > $width)? $width : $w;
                $newH = $h * ($newW / $w);
            } else {
                //$newH = $height;
                $newH = ($h > $height)? $height : $h;
                $newW = $w * ($newH / $h);
            }

            $newIm = imagecreatetruecolor($width,$height);//$newW, $newH);
            imagealphablending($newIm, false);
            $colorTransparent = imagecolorallocatealpha($newIm, 255, 255, 255, 127);
            imagefill($newIm, 0, 0, $colorTransparent);
            imagesavealpha($newIm, true);
            imagecopyresampled($newIm, $this->im, (($width-$newW)/2), (($height-$newH)/2), 0, 0, $newW, $newH, $w, $h);
            imagedestroy($this->im);

            $this->im = $newIm;

            return $this;
        }

        public function saveToFile($imagePath) {
            if(file_exists($imagePath) && !is_writable($imagePath)) throw new Exception("$imagePath is not writable!");

            imagejpeg($this->im, $imagePath);
        }

        public function show() {
            header('Content-Disposition: Attachment;filename=image.png');
            header('Content-type: image/png');
            imagepng($this->im);
        }

    }

?>