public function rotate($deg)
{
// Create a new image resource and rotate it.
$this->createResource();
$color = $this->setColor($this->backgroundColor);
$this->output = imagerotate($this->resource, $deg, $color);
$this->resource = $this->output;
return $this;
}