+ /**
+ * @param FileInterface $file
+ * @return CropVariant
+ */
+ public function applyRatioRestrictionToSelectedCropArea(FileInterface $file): CropVariant
+ {
+ if (!$this->selectedRatio) {
+ return $this;
+ }
+ $newVariant = clone $this;
+ $newArea = $this->cropArea->makeAbsoluteBasedOnFile($file);
+ $newArea = $newArea->applyRatioRestriction($this->allowedAspectRatios[$this->selectedRatio]);
+ $newVariant->cropArea = $newArea->makeRelativeBasedOnFile($file);
+ return $newVariant;
+ }
+