Instead of using the global operator, define the space that you want the image to go in (it should be a path that is a rectangle, except for rounded corners).
Then put this path in context before drawing the image, call .clip (), and then draw the image.
Then the image will be drawn with rounded corners at the two corners of the image.
, , .
:
ctx.save();
ctx.beginPath();
ctx.closePath();
ctx.clip();
ctx.restore();