/** * Saves a new image from a file found on the server's filesystem. * * @param File $file * @param \TippingCanoe\Imager\Model\Imageable|\Illuminate\Database\Eloquent\Model $imageable * @param array $attributes * @throws Exception * @return null */ public function saveFromFile(File $file, Imageable $imageable = null, array $attributes = []) { if (!array_key_exists($file->getMimeType(), Mime::getTypes())) { throw new Exception(sprintf('File type %s not supported', $file->getMimeType())); } $image = $this->createImageRecord($file, $attributes); // Believe it or not, imageables are optional! if ($imageable) { $imageable->images()->save($image); } $this->saveFile($file, $image); return $image; }