public function contain($width, $height)
{
$x = $this->getWidth() / $width;
$y = $this->getHeight() / $height;
if ($x <= 1 && $y <= 1 && !$this->isVectorGraphic()) {
return $this;
} elseif ($x > $y) {
$this->scaleByWidth($width);
} else {
$this->scaleByHeight($height);
}
return $this;
}