Nette\Http\FileUpload::getImageSize PHP Method

getImageSize() public method

Returns the dimensions of an uploaded image as array.
public getImageSize ( ) : array | null
return array | null
    public function getImageSize()
    {
        return $this->isOk() ? @getimagesize($this->tmpName) : NULL;
        // @ - files smaller than 12 bytes causes read error
    }

Usage Example

コード例 #1
0
ファイル: Image.php プロジェクト: blitzik/CMS
 public function __construct(FileUpload $file)
 {
     if (!$file->isImage()) {
         throw new NotImageUploadedException();
     }
     $this->id = Uuid::uuid4();
     $pathInfo = pathinfo($file->getSanitizedName());
     if (!isset($pathInfo['extension'])) {
         throw new FileNameException('Filename must have extension');
     }
     $this->extension = $pathInfo['extension'];
     $this->originalName = $pathInfo['filename'];
     $imgSize = $file->getImageSize();
     $this->width = $imgSize[0];
     $this->height = $imgSize[1];
     $this->fileSize = $file->getSize();
     $this->uploadedAt = new \DateTime('now');
 }