height($desiredHeight); } else { $this->width($desiredWidth); } } $currentAspectRatio = $originalWidth / $originalHeight; $desiredAspectRatio = $desiredWidth / $desiredHeight; if ($currentAspectRatio > $desiredAspectRatio) { $this->height($desiredHeight); } else { $this->width($desiredWidth); } $this->resizeCanvas($desiredWidth, $desiredHeight, AlignPosition::Center); return $this; } }