public static function CheckImageSize($fileName, $maxWidth, $maxHeight) { list($width, $height) = ImageUtils::GetImageSize($fileName); if ($width > $maxWidth || $height > $maxHeight) { return false; } else { return true; } }
protected function CheckValueIsCorrect($value) { if (!isset($value)) { return; } $filename = $value; if ($this->sizeCheckEnabled) { if (filesize($filename) > $this->maxSize) { throw new FileSizeExceedMaxSize($this->GetFieldName(), filesize($filename), $this->maxSize); } } if ($this->imageSizeCheckEnabled) { if (!ImageUtils::CheckImageSize($filename, $this->maxWidth, $this->maxHeight)) { list($actualWidth, $actualHeight) = ImageUtils::GetImageSize($filename); throw new ImageSizeExceedMaxSize($this->GetFieldName(), $actualWidth, $actualHeight, $this->maxWidth, $this->maxHeight); } } }