'jpeg', 'jpeg' => 'jpeg', 'png' => 'png', 'gif' => 'gif', 'bmp' => 'bmp', ]; /** * Try to load image and prepare it to manipulation. * * @param null|string $file * @param null|string $driver * * @return \yii\image\drivers\Image * @throws \yii\base\ErrorException */ public function load($file = null, $driver = null) { if (empty( $file ) || !realpath($file)) { throw new ErrorException('File name can not be empty and exists'); } return Image::factory($file, $driver ? $driver : $this->driver); } }