Beispiel #1
0
 /**
  * @param string $fileName
  *
  * @throws \Exception
  * @return ImageInterface
  *
  * @todo add more sophisticated checks by inspecting file
  */
 public static function fromFile($fileName)
 {
     $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
     switch ($ext) {
         case 'jpg':
         case 'jpeg':
             return Format\JPEG::fromFile($fileName);
             break;
         case 'png':
             return Format\PNG::fromFile($fileName);
             break;
         case 'webp':
             return Format\WebP::fromFile($fileName);
             break;
         case 'psd':
             return Format\PSD::fromFile($fileName);
             break;
     }
     throw new \Exception('Unrecognised file name');
 }