In Fabric.js canvas, I'm trying to replace the src of an image object with a high resolution image to maintain image quality when using canvas.toDataURLWithMultiplier .
When I change the src of an image object, all its properties also change. The image object is scaled to a different size automatically and all state properties change.
This comes from version 0.9.15. When I use version 0.8.32, it works. Version 0.8.32 does not have this problem.
Here is the code:
<body> <button id="click" onclick="changeImage()">Change Image</button> <canvas id="canvas" width="300px" height="300px" style="border:2px solid #000;"> <script> canvas = new fabric.Canvas('canvas'); fabric.Image.fromURL("http://timeplusq.com/dakshin/clip03.png", function(obj) { canvas.add(obj.scale(1).rotate(-15).set({ left: 80, top: 95 })); }); function changeImage(){ var tmp=canvas.item(0).getElement(); var src = tmp.src; tmp.setAttribute("src", 'http://timeplusq.com/dakshin/clip03original.png'); </script> </body>
I tried to get the initial state properties of the image object, and then set the values ββfor the modified image object. But that did not work.
Any solution to this problem?
source share