private function resizeJPG($width, $height, $imageWithPath, $filename)
{
$compression = 100;
$img = imagecreatefromjpeg( $imageWithPath );
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $img, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
imagejpeg($new_image, self::thumbnail_path . $filename, $compression);
}
private function resizePNG($width, $height, $imageWithPath, $filename)
{
$img = imagecreatefrompng( $imageWithPath );
$tmp_img = imagecreatetruecolor( $width, $height );
imagealphablending($tmp_img, false);
imagesavealpha($tmp_img,true);
$transparent = imagecolorallocatealpha($tmp_img, 255, 255, 255, 127);
imagefilledrectangle($tmp_img, 0, 0, $width, $height, $transparent);
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );
imagepng( $tmp_img, self::thumbnail_path . $filename );
}
private function resizeGIF($width, $height, $imageWithPath, $filename)
{
$img = imagecreatefromgif( $imageWithPath );
$tmp_img = imagecreatetruecolor($width, $height);
$trnprt_indx = imagecolortransparent( $imageWithPath );
if ($trnprt_indx >= 0) {
$trnprt_color = imagecolorsforindex($imageWithPath, $trnprt_indx);
$trnprt_indx = imagecolorallocate($tmp_img, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
imagefill($tmp_img, 0, 0, $trnprt_indx);
imagecolortransparent($tmp_img, $trnprt_indx);
}
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
imagegif( $tmp_img, self::thumbnail_path . $filename );
}