/** * @param $input * @param $output * @param ImageSize $expectedSize * @param string $resize_type * @param int $quality * @return bool */ public function resize($input, $output, ImageSize $expectedSize, $resize_type = ImageResizer::RESIZE_TYPE_AUTO, $quality = 80) { $img = imagecreatefromstring(file_get_contents($input)); if (!$img) { // if can't open and create the image return false; } if (function_exists('exif_imagetype')) { $type = exif_imagetype($input); } else { $info = getimagesize($input); $type = $info[2]; unset($info); } $originalSize = new ImageSize(imagesx($img), imagesy($img)); // Get optimal size based on resizing type $newSize = $originalSize->getResizedSize($expectedSize, $resize_type); $imageResized = $this->resizeImage($img, $type, $originalSize, $newSize); if ($resize_type === ImageResizer::RESIZE_TYPE_CROP) { $imageResized = $this->crop($imageResized, $type, $newSize, $expectedSize); } return $this->saveImage($imageResized, $type, $output, $quality); }