setupImage(); } protected function setupImage() { if (!isset($this->options['accept'])) { $this->options['accept'] = []; } $this->options['accept']['mimeTypes'] = 'image/*'; $this->options['isImage'] = true; } /** * @param array $options support: * [ * 'width' => 100, * 'height' => 100, * 'min_width' => 100, * 'min_height' => 100, * 'max_width' => 100, * 'max_height' => 100, * 'ratio' => 3/2, // (width / height) * ] * @return $this */ public function dimensions(array $options) { if (!$options) return $this; $this->options(['dimensions' => $options]); foreach ($options as $k => &$v) { $v = "$k=$v"; } return $this->rules('dimensions:'.join(',', $options)); } /** * Set ratio constraint. * * @param float $ratio width/height * @return $this */ public function ratio($ratio) { if ($ratio <= 0) { return $this; } return $this->dimensions(['ratio' => $ratio]); } /** * @param UploadedFile $file * */ protected function prepareFile(UploadedFile $file) { $this->callInterventionMethods($file->getRealPath(), $file->getMimeType()); } }