65 $file = $aFile[
'tmp_name'];
66 preg_match(
"#/([a-z]+)#is", $aFile[
'type'], $regs);
77 if(!function_exists(
"imageJPEG") || !function_exists(
"imagecreatefromjpeg"))
81 if(!function_exists(
"imageGIF") || !function_exists(
"imagecreatefromgif"))
85 if(!function_exists(
"imagePNG") || !function_exists(
"imagecreatefrompng"))
95 $imageInput = imagecreatefromjpeg($file);
99 $imageInput = imagecreatefromgif($file);
102 $imageInput = imagecreatefrompng($file);
106 $imgX = imagesx($imageInput);
107 $imgY = imagesy($imageInput);
109 if ($imgX > $sizeX || $imgY > $sizeY)
112 $newY = $imgY * ($newX / $imgX);
117 $newX = $imgX * ($newY / $imgY);
120 if (function_exists(
"imagecreatetruecolor"))
121 $imageOutput = ImageCreateTrueColor($newX, $newY);
123 $imageOutput = ImageCreate($newX, $newY);
125 if(function_exists(
"imagecopyresampled"))
126 imagecopyresampled($imageOutput, $imageInput, 0, 0, 0, 0, $newX, $newY, $imgX, $imgY);
128 imagecopyresized($imageOutput, $imageInput, 0, 0, 0, 0, $newX, $newY, $imgX, $imgY);
133 return (imageJPEG($imageOutput, $file));
135 return (imageGIF($imageOutput, $file));
137 return (imagePNG($imageOutput, $file));