public function transform(CGImageBase $src)
 {
     if ($this->_angle == 0) {
         return $src;
     }
     // nothing to do.
     $type = $src['type'];
     if ($this->_alpha != 0) {
         $type = 'image/png';
     }
     if ($this->_alpha == 127) {
         $this->_color = 'transparent';
     }
     if ($this->_color == 'transparent') {
         $type = 'image/png';
     }
     if (!function_exists('imagerotate')) {
         throw new Exception('imagerotate function not found');
     }
     $_dest = new CGImageBase(array($type, $src['width'], $src['height']));
     if (!$this->_color || $this->_color == 'transparent') {
         $tcolor = cgsi_utils::get_transparent_color($src);
     } else {
         list($_r, $_g, $_b) = cgsi_utils::color_to_rgb($this->_color);
         $tcolor = imagecolorallocatealpha($_dest['rsrc'], $_r, $_g, $_b, $this->_alpha);
     }
     $res = imagerotate($src['rsrc'], $this->_angle * -1, $tcolor);
     if ($res === FALSE) {
         throw new Exception('Error applying filter ' . IMG_FILTER_COLORIZE);
     }
     imagecolortransparent($res, $tcolor);
     $_dest['rsrc'] = $res;
     $_dest['width'] = imagesx($res);
     $_dest['height'] = imagesy($res);
     return $_dest;
 }