public function getImageAt($width = null, $height = null, $upscale = false)
{
if (!$this->owner->exists()) {
return $this->owner;
}
$realWidth = $this->owner->getWidth();
$realHeight = $this->owner->getHeight();
if ($width && $height) {
return $realWidth < $width && $realHeight < $height && !$upscale ? $this->owner : $this->owner->Fit($width, $height);
} else {
if ($width) {
return $realWidth < $width && !$upscale ? $this->owner : $this->owner->ScaleWidth($width);
} else {
return $realHeight < $height && !$upscale ? $this->owner : $this->owner->ScaleHeight($height);
}
}
}