public static function createByFileName($fileName) { $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $anyImageType = new self(self::getAnyId()); $extensionList = $anyImageType->getExtensionList(); if (isset($extensionList[$ext])) { return new self($extensionList[$ext]); } throw new WrongArgumentException("don't know type for '{$ext}' extension"); }