更新时间:2022-10-19 13:30:18
我尽力了解你的问题,我试图回答
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();
让我知道它是错误的还是更新您的问题是可以理解的:)
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 = $('#thumbnail').css('height')
console.log(width);
console.log(heigth);
$('#thumbnail').css('height', width).css('width', heigth);
ctx.clearRect(0,0,c.width,c.height);
ctx.save();
ctx.translate(0, c.width/2, c.height/2);
ctx.rotate(90 * Math.PI/180);
ctx.translate(c.width/2, c.height/2);
ctx.drawImage(img,-img.width/2, -img.height/2);
ctx.restore();
The canvas size is the image size reduce by ratio. But the result is not expected. The picture is scaled to 200% (zoom-in).
If have no solution in js, explain me how I can add exif to canvas.
Thanks!
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 :)