Skip to content Skip to sidebar Skip to footer

Javascript Canvas Rotate Image

I have a image with exif orientation at 6! I'm scaling the image in canvas (to reduce with proportion) like this: var width = $('#thumbnail').css('width') var heigth = $('#thu

Solution 1:

I have tried my best to understand your question darkiron so here is my attempt at answering

jsFiddle : https://jsfiddle.net/20w7u4qc/

javascript

ctx.clearRect(0, 0, c.width, c.height);
ctx.save();
ctx.translate(c.width / 2, c.height / 2);
ctx.rotate(90 * Math.PI / 180);
ctx.translate(-c.width / 2, -c.height / 2);
ctx.drawImage(img, 0, 0);
ctx.restore();

Let me know if it is wrong or if you update your question to be understandable :)

Post a Comment for "Javascript Canvas Rotate Image"