degrees = 75;
//calculate new image size & rectangle from original image dims
plus degrees of rotation
imageWidth = [image size].width;
imageHeight = [image size].height;
imageRect = NSMakeRect(0,0,imageWidth,imageHeight);
//calculate via trig the new image size.
w1 = cos(degrees * pi/180) * imageWidth;
w2 = cos((90-degrees) * pi/180) * imageHeight;
h1 = sin(degrees * pi/180) * imageWidth;
h2 = sin((90-degrees) * pi/180) * imageHeight;
newImageWidth = w1 + w2;
newImageHeight = h1 + h2;
newImageRect = NSMakeRect(0,0,newImageWidth,newImageHeight);
//rotation point of image
centrePoint = NSMakePoint(NSMidX(imageRect), NSMidY(imageRect));
// offset to centre point of new image size.
imageOffset = NSMakePoint((newImageWidth - imageWidth)/2,
(newImageHeight - imageHeight)/2);
NSRect dstRect = NSMakeRect(-imageOffset.x,-
imageOffset.y,newImageWidth,newImageHeight);
[self setFrame:dstRect];
[self setBounds:dstRect];
[transform translateXBy:centrePoint.x yBy:centrePoint.y];
[transform rotateByDegrees:degrees];
[transform translateXBy:-centrePoint.x yBy:-centrePoint.y];
[transform concat];
[image drawInRect:imageRect fromRect:imageRect
operation:NSCompositeCopy fraction:opacity];