You can use context transforms (scaling) to scale your original image with transparent background.
- save the unscaled context state.
- translate to the center of the canvas
- draw the scaled image offset by half the image width and height
- restore the unscaled context state.
Here's example code and a Demo: http://jsfiddle.net/m1erickson/765Jt/
function drawScaled(img,scaleFactor,canvas,ctx){
var cw=canvas.width;
var ch=canvas.height;
var scaledIW=img.width*scaleFactor;
var scaledIH=img.height*scaleFactor;
// save the unscaled context state
ctx.save();
// translate to the center of the canvas
// Note: the 0,0 coordinate is now center-canvas
ctx.translate(cw/2,ch/2);
// draw the image using the extended drawImage scaling ability
// be sure to offset your canvas drawing by half the image size
// since the 0,0 coordinate is now center-canvas
ctx.drawImage(img,
0,0,img.width,img.height,
-scaledIW/2,-scaledIH/2,scaledIW,scaledIH
);
ctx.restore();
}