11-11-2008, 07:16 PM
|
#2 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Nevermind! I solved that. Now it's just the thumbnail part that doesn't work:
php Code:
private function createThumb () { switch($_FILES[ $this-> form_inputName][ 'type'] ) { case 'image/jpeg': $srcimage = imagecreatefromjpeg ($this-> image_bigPath . $this-> file_name); break; case 'image/gif': $srcimage = imagecreatefromgif ($this-> image_bigPath . $this-> file_name); break; case 'image/png': $srcimage = imagecreatefrompng ($this-> image_bigPath . $this-> file_name); break; default: $srcimage = imagecreatefromjpeg ($this-> image_bigPath . $this-> file_name); } $srcimagex = imagesx ($srcimage); $srcimagey = imagesy ($srcimage); if($srcimagex > $this-> thumb_width || $srcimagey > $this-> thumb_height) { if($srcimagex > $srcimagey) $ratio = $this-> thumb_width / $srcimagex; elseif($srcimagex < $srcimagey) $ratio = $this-> thumb_height / $srcimagex; else $ratio = (($this-> thumb_width + $this-> thumb_height) / 2) / $srcimagey; $thumbwidth = $srcimagex * $ratio; $thumbheight = $srcimagey * $ratio; $thumbnail = imagecreatetruecolor ($thumbwidth, $thumbheight); imagecopyresampled ($thumbnail, $srcimage, 0, 0, 0, 0, $thumbwidth, $thumbheight, $srcimagex, $srcimagey); $success = imagejpeg ($thumbnail, $this-> image_thuPath . $this-> file_name, 75); if($success) { $this-> thumb_creation = 1; unlink($this-> image_thuPath . $this-> file_name); } else throw new Exception ('Thumbnail creation did not work.'); } }
__________________
Last edited by Tanax : 11-11-2008 at 07:48 PM.
|
|
|
|