width, $photo->height ); $tempName = tempnam('/tmp', 'blue_twilight_thumbnail_'); rename($tempName, $tempName . '.jpg'); // TODO make thumbnail quality configurable imagejpeg($thumbnailImageResource, $tempName . '.jpg', 90); } public function openImage($imagePath, &$imageInfo) { $imageInfo = getimagesize($imagePath); $im = false; $type = $imageInfo[2]; $allowedTypes = [ IMG_GIF, IMG_PNG, IMG_JPEG, IMG_WBMP ]; if (!in_array($type, $allowedTypes)) { return false; } switch ($type) { case IMG_GIF: $im = imagecreatefromgif($imagePath); break; case IMG_JPEG: $im = imagecreatefromjpeg($imagePath); break; case IMG_PNG: $im = imagecreatefrompng($imagePath); break; case IMG_WBMP: $im = imagecreatefromwbmp($imagePath); break; } return $im; } }