save_dir = $save_directory; $this->width = $max_width; $this->height = $max_height; //--change filename to time - make it unique $temp_filename = $file_array['name']; $ext = explode('.',$temp_filename); $ext = $ext[count($ext)-1]; $temp_filename = time().".".$ext; //--check that it's a jpeg or gif if (preg_match('/^(gif|jpe?g)$/',$ext)) { // resize in proportion list($width_orig, $height_orig) = getimagesize($file_array['tmp_name']); if ($this->width && ($width_orig < $height_orig)) { $this->width = ($this->height / $height_orig) * $width_orig; } else { $this->height = ($this->width / $width_orig) * $height_orig; } $image_p = imagecreatetruecolor($this->width, $this->height); //handle gifs and jpegs separately if($ext=='gif'){ $image = imagecreatefromgif($file_array['tmp_name']); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $this->width, $this->height, $width_orig, $height_orig); imagegif($image_p, $this->save_dir.$temp_filename, 80); } else { $image = imagecreatefromjpeg($file_array['tmp_name']); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $this->width, $this->height, $width_orig, $height_orig); imagejpeg($image_p, $this->save_dir.$temp_filename, 80); } imagedestroy($image_p); imagedestroy($image); $this->filename=$temp_filename; }else{ $this->error_message.="
file is not a jpeg or gif picture
"; } } } ?>