function rotate($angle, $bg_color = '#000000')
{
// Perform the rotation
$rgba = $this->normalize_color($bg_color);
$bg_color = imagecolorallocatealpha($this->image, $rgba['r'], $rgba['g'], $rgba['b'], $rgba['a']);
$new = imagerotate($this->image, -$this->keep_within($angle, -360, 360), $bg_color);
imagesavealpha($new, true);
imagealphablending($new, true);
// Update meta data
$this->width = imagesx($new);
$this->height = imagesy($new);
$this->image = $new;
return $this;
}