html頁面中圖片加水印
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<canvas id="myCanvas" width="1000" height="500" >
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
// 準備img對象
var img = new Image();
img.src = 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4243577976,1636137391&fm=27&gp=0.jpg';
// 加載圖片
img.onload=function(){
//準備canvas對象
var canvas=document.getElementById("myCanvas");
var ctx=canvas.getContext("2d");
// 繪製圖片
ctx.drawImage(img,0,0);
// 繪製水印
ctx.font="20px microsoft yahei";
ctx.fillStyle = "rgba(0,0,0,1)";
ctx.fillText("my images",100,100);
}
</script>
</body>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.