/**
  * @param DocumentInterface $document
  * @param                   value
  *
  * @return array|null|UploadedFile
  */
 public function onDocumentUpdating(DocumentInterface $document, $value)
 {
     parent::onDocumentUpdating($document, $value);
     if (is_null($value) or $this->isRemoveFile) {
         return;
     }
     $image = (new ImageManager())->make($this->getFilePath($value));
     $width = $this->getWidth();
     $height = $this->getHeight();
     $crop = $this->isCropable();
     $aspectRatio = $this->aspectRatio();
     if ($width > 0 and empty($height)) {
         $image->widen($width);
     } elseif (empty($width) and $height > 0) {
         $image->heighten($height);
     } elseif ($width > 0 and $height > 0) {
         $image->resize($width, $height, function ($constraint) use($aspectRatio) {
             if ($aspectRatio) {
                 $constraint->aspectRatio();
             }
         });
         if ($crop) {
             $image->crop($width, $height);
         }
     }
     $image->save($value, $this->getQuality());
 }