if ($this->mime_type == "image/jpeg") { $new_image = imagecreatefromjpeg($destination.$this->md5_name); $blank_image = ImageCreateTrueColor($new_width, $new_height); $col = imagecolorallocate($blank_image, $this->red, $this->green, $this->blue); imagefilledrectangle($blank_image, 0, 0, $new_width, $new_height, $col); $newimage = ImageCopyResampled($blank_image, $new_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($blank_image, $destination."thumbs/".$this->md5_name.$t['suffix']); } elseif ($this->mime_type == "image/gif") { $new_image = imagecreatefromgif($destination.$this->md5_name); $blank_image = ImageCreateTrueColor($new_width, $new_height); $col = imagecolorallocate($blank_image, $this->red, $this->green, $this->blue); imagefilledrectangle($blank_image, 0, 0, $new_width, $new_height, $col); $newimage = ImageCopyResampled($blank_image, $new_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagegif($blank_image, $destination."thumbs/".$this->md5_name.$t['suffix']); } elseif ($this->mime_type == "image/png") { $new_image = imagecreatefrompng($destination.$this->md5_name); $blank_image = ImageCreateTrueColor($new_width, $new_height); $col = imagecolorallocate($blank_image, $this->red, $this->green, $this->blue); imagefilledrectangle($blank_image, 0, 0, $new_width, $new_height, $col); $newimage = ImageCopyResampled($blank_image, $new_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagepng($blank_image, $destination."thumbs/".$this->md5_name.$t['suffix']); }