public function frame($width, $height)
{
$this->preModify();
$this->contain($width, $height);
$x = ($width - $this->getWidth()) / 2;
$y = ($height - $this->getHeight()) / 2;
$newImage = $this->createImage($width, $height);
imagecopy($newImage, $this->resource, $x, $y, 0, 0, $this->getWidth(), $this->getHeight());
$this->resource = $newImage;
$this->setWidth($width);
$this->setHeight($height);
$this->postModify();
$this->setIsAlphaPossible(true);
return $this;
}