吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1800|回复: 52
收起左侧

[其他转载] 身份证添加水印源码-大模型写的

[复制链接]
evlon 发表于 2025-3-24 14:55
本帖最后由 evlon 于 2025-3-25 10:51 编辑

保存为HTML文件使用,比如 身份证水印.html

版本变化,增加了颜色,增加了原图分辨率下载

源码如下:


<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>身份证水印工具</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 20px;
            background-color: #f0f0f0;
        }
        h1 {
            color: #333;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        input[type="file"], input[type="text"], select, input[type="number"], input[type="range"], input[type="color"] {
            margin: 10px 0;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            width: 300px;
        }
        button {
            margin: 10px;
            padding: 10px 20px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        #canvas {
            margin-top: 20px;
            border: 1px solid #ccc;
            box-shadow: 0 0 5px rgba(0,0,0,0.2);
            display: none; /* 初始隐藏 canvas */
        }
        .options {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
            width: 100%;
        }
        .option-group {
            margin: 10px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>身份证水印工具</h1>
        <input type="file" id="upload" accept="image/*">
        <input type="text" id="watermark-text" placeholder="输入水印文字">
        <div class="options">
            <div class="option-group">
                <label for="font-size">文字大小:</label>
                <select id="font-size">
                    <option value="12">12px</option>
                    <option value="16">16px</option>
                    <option value="20" selected>20px</option>
                    <option value="24">24px</option>
                </select>
            </div>
            <div class="option-group">
                <label for="rotation">旋转角度(度):</label>
                <input type="number" id="rotation" value="-45" step="1">
            </div>
            <div class="option-group">
                <label for="font-family">字体:</label>
                <select id="font-family">
                    <option value="Arial" selected>Arial</option>
                    <option value="Times New Roman">Times New Roman</option>
                    <option value="Courier New">Courier New</option>
                    <option value="Verdana">Verdana</option>
                </select>
            </div>
            <div class="option-group">
                <label for="opacity">透明度(0-100):</label>
                <input type="range" id="opacity" min="0" max="100" value="50">
            </div>
            <div class="option-group">
                <label for="horizontal-spacing">水平间距(像素):</label>
                <input type="number" id="horizontal-spacing" value="50" min="10" step="10">
            </div>
            <div class="option-group">
                <label for="vertical-spacing">行间距(像素):</label>
                <input type="number" id="vertical-spacing" value="100" min="10" step="10">
            </div>
            <div class="option-group">
                <label for="font-color">字体颜色:</label>
                <input type="color" id="font-color" value="#FFFFFF">
            </div>
        </div>
        <button id="add-watermark">添加水印</button>
        <canvas id="canvas"></canvas>
        <button id="download" style="display: none;">下载图片</button>
    </div>

    <script>
        let originalImage = null;
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');

        // 上传图片
        document.getElementById('upload').addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (!file) return;

            const reader = new FileReader();
            reader.onload = function(event) {
                const img = new Image();
                img.onload = function() {
                    originalImage = img;
                    // 动态设置 canvas 尺寸为原图尺寸
                    canvas.width = img.width;
                    canvas.height = img.height;
                    // 绘制原图
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
                    document.getElementById('download').style.display = 'none';
                    // 显示 canvas
                    canvas.style.display = 'block';
                };
                img.src = event.target.result;
            };
            reader.readAsDataURL(file);
        });

        // 添加水印
        document.getElementById('add-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片');
                return;
            }
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字');
                return;
            }
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const fontColor = document.getElementById('font-color').value;

            // 清除 canvas 并重新绘制原图
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.drawImage(originalImage, 0, 0, canvas.width, canvas.height);

            // 设置水印样式
            ctx.font = `${fontSize}px ${fontFamily}`;
            ctx.fillStyle = `rgba(${parseInt(fontColor.slice(1, 3), 16)}, ${parseInt(fontColor.slice(3, 5), 16)}, ${parseInt(fontColor.slice(5, 7), 16)}, ${opacity})`;
            ctx.textBaseline = 'middle';
            ctx.save();
            // 移动到 canvas 中心并旋转
            ctx.translate(canvas.width / 2, canvas.height / 2);
            const angle = rotation * Math.PI / 180;
            ctx.rotate(angle);
            // 计算水印布局
            const textWidth = ctx.measureText(text).width;
            const diagonal = Math.sqrt(canvas.width * canvas.width + canvas.height * canvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
            // 绘制水印
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    ctx.fillText(text, x, y);
                }
            }
            ctx.restore();
            document.getElementById('download').style.display = 'inline-block';
        });

        // 下载图片
        document.getElementById('download').addEventListener('click', function() {
            const dataURL = canvas.toDataURL('image/png');
            const a = document.createElement('a');
            a.href = dataURL;
            a.download = 'watermarked-image.png';
            a.click();
        });
    </script>
</body>
</html>```

1.png
wechat_2025-03-24_145424_860.png

免费评分

参与人数 8吾爱币 +7 热心值 +7 收起 理由
maxixia + 1 + 1 我很赞同!
sirchin + 1 + 1 谢谢@Thanks!
chao0927 + 1 我很赞同!
PlusVV + 1 thx,刚好有需求,之前都是用ps做,现在更方便了~
快乐的小驹 + 1 + 1 谢谢@Thanks!
whodead + 1 + 1 我很赞同!
djy597060921 + 1 + 1 若导出的图片和原图片分辨率保持一致更佳。
sohuso + 1 + 1 挺方便,建议增加字体颜色功能

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

zl33333 发表于 2025-3-24 16:00
[HTML] 纯文本查看 复制代码
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>&#127752;&#10024; 可爱身份证水印工具 &#10024;&#127752;</title>
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-color: #FF85A2;
            --secondary-color: #FFC2D1;
            --accent-color: #7CB9E8;
            --text-color: #5E5E5E;
            --light-bg: #FFF0F5;
            --card-bg: #FFFFFF;
            --success-color: #A0E7A0;
            --warning-color: #FFD700;
            --shadow: 0 8px 20px rgba(255, 133, 162, 0.2);
            --border-radius: 16px;
        }
 
        * {
            box-sizing: border-box;
            transition: all 0.3s ease;
        }
 
        body {
            font-family: 'Nunito', Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 0;
            padding: 20px;
            background-color: var(--light-bg);
            background-image:
                radial-gradient(circle at 10% 20%, rgba(255, 194, 209, 0.3) 0%, transparent 20%),
                radial-gradient(circle at 90% 30%, rgba(124, 185, 232, 0.3) 0%, transparent 20%),
                radial-gradient(circle at 50% 80%, rgba(160, 231, 160, 0.3) 0%, transparent 20%);
            color: var(--text-color);
            min-height: 100vh;
        }
 
        .container {
            background-color: var(--card-bg);
            padding: 30px;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            display: flex;
            flex-direction: column;
            align-items: center;
            max-width: 800px;
            width: 100%;
            margin-top: 20px;
            position: relative;
            overflow: hidden;
        }
 
        .container::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 8px;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
            border-radius: var(--border-radius) var(--border-radius) 0 0;
        }
 
        h1 {
            color: var(--primary-color);
            margin-bottom: 25px;
            text-align: center;
            font-weight: 700;
            font-size: 2.2rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
        }
 
        .emoji-title {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            flex-wrap: wrap;
        }
 
        .emoji-title .emoji {
            font-size: 2.5rem;
            animation: bounce 2s infinite alternate;
        }
 
        @keyframes bounce {
            0% { transform: translateY(0); }
            100% { transform: translateY(-10px); }
        }
 
        .upload-area {
            border: 3px dashed var(--secondary-color);
            border-radius: var(--border-radius);
            padding: 30px;
            text-align: center;
            width: 100%;
            margin-bottom: 20px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            background-color: rgba(255, 240, 245, 0.5);
        }
 
        .upload-area:hover {
            border-color: var(--primary-color);
            background-color: rgba(255, 240, 245, 0.8);
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(255, 133, 162, 0.3);
        }
 
        .upload-icon {
            font-size: 3rem;
            margin-bottom: 10px;
            color: var(--primary-color);
        }
 
        .upload-text {
            font-size: 1.2rem;
            color: var(--text-color);
            margin-bottom: 10px;
        }
 
        .file-input {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
        }
 
        .input-group {
            width: 100%;
            margin-bottom: 15px;
            position: relative;
        }
 
        .cute-input {
            width: 100%;
            padding: 12px 20px;
            border: 2px solid var(--secondary-color);
            border-radius: 25px;
            font-size: 1rem;
            color: var(--text-color);
            background-color: #FFFFFF;
            outline: none;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(255, 133, 162, 0.2);
        }
 
        .input-icon {
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--primary-color);
            font-size: 1.2rem;
        }
 
        .options-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            width: 100%;
            margin-bottom: 20px;
        }
 
        .option-group {
            display: flex;
            flex-direction: column;
            background-color: rgba(255, 240, 245, 0.5);
            padding: 15px;
            border-radius: var(--border-radius);
            border: 2px solid var(--secondary-color);
        }
 
        .option-group:hover {
            border-color: var(--primary-color);
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(255, 133, 162, 0.2);
        }
 
        .option-label {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
            font-weight: 600;
            color: var(--primary-color);
        }
 
        .option-label .emoji {
            margin-right: 8px;
            font-size: 1.2rem;
        }
 
        .cute-select, .cute-range, .cute-number {
            width: 100%;
            padding: 10px 15px;
            border: 2px solid var(--secondary-color);
            border-radius: 20px;
            font-size: 0.9rem;
            color: var(--text-color);
            background-color: #FFFFFF;
            outline: none;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-select:focus, .cute-range:focus, .cute-number:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(255, 133, 162, 0.2);
        }
 
        .cute-range {
            -webkit-appearance: none;
            height: 10px;
            background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
            border-radius: 5px;
            outline: none;
            padding: 0;
        }
 
        .cute-range::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--primary-color);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
        }
 
        .cute-range::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--primary-color);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
        }
 
        .cute-button {
            padding: 12px 25px;
            background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            box-shadow: 0 4px 15px rgba(255, 133, 162, 0.3);
            margin: 10px;
            transition: all 0.3s ease;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(255, 133, 162, 0.4);
        }
 
        .cute-button:active {
            transform: translateY(1px);
            box-shadow: 0 2px 10px rgba(255, 133, 162, 0.3);
        }
 
        .button-container {
            display: flex;
            justify-content: center;
            margin: 20px 0;
            flex-wrap: wrap;
            gap: 10px;
        }
 
        .canvas-container {
            position: relative;
            margin: 20px 0;
            border-radius: var(--border-radius);
            overflow: hidden;
            box-shadow: var(--shadow);
            background-color: #f0f0f0;
            background-image:
                linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
                linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
                linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
            background-size: 20px 20px;
            background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
            width: 100%;
            max-width: 600px;
        }
 
        #canvas {
            display: block;
            max-width: 100%;
            height: auto;
        }
 
        .security-notice {
            background-color: var(--success-color);
            color: #2E7D32;
            padding: 15px;
            border-radius: var(--border-radius);
            margin-top: 20px;
            text-align: center;
            font-size: 0.95rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            box-shadow: 0 4px 10px rgba(160, 231, 160, 0.3);
            flex-wrap: wrap;
        }
 
        .tooltip {
            position: relative;
            display: inline-block;
            margin-left: 5px;
            cursor: help;
        }
 
        .tooltip .tooltip-text {
            visibility: hidden;
            width: 220px;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 8px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 0.85rem;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        }
 
        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }
 
        .loading {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10;
            border-radius: var(--border-radius);
            display: none;
        }
 
        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 5px solid var(--secondary-color);
            border-top: 5px solid var(--primary-color);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
 
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
 
        .footer {
            margin-top: 30px;
            text-align: center;
            color: var(--text-color);
            font-size: 0.9rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }
 
        .heart {
            color: var(--primary-color);
            animation: heartbeat 1.5s infinite;
            font-size: 1.2rem;
        }
 
        @keyframes heartbeat {
            0% { transform: scale(1); }
            5% { transform: scale(1.2); }
            10% { transform: scale(1); }
            15% { transform: scale(1.2); }
            20% { transform: scale(1); }
            100% { transform: scale(1); }
        }
 
        /* 彩虹文字效果 */
        .rainbow-text {
            background-image: linear-gradient(90deg,
                #FF85A2, #FFA07A, #FFD700, #A0E7A0, #7CB9E8, #9370DB, #FF85A2);
            background-size: 600% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: rainbow 6s linear infinite;
        }
 
        @keyframes rainbow {
            0% { background-position: 0% 50%; }
            100% { background-position: 100% 50%; }
        }
 
        /* 可爱的复选框 */
        .cute-checkbox {
            display: flex;
            align-items: center;
            margin-top: 10px;
        }
 
        .cute-checkbox input[type="checkbox"] {
            display: none;
        }
 
        .cute-checkbox label {
            display: flex;
            align-items: center;
            cursor: pointer;
            user-select: none;
            color: var(--text-color);
        }
 
        .cute-checkbox .checkbox-custom {
            width: 24px;
            height: 24px;
            border: 2px solid var(--secondary-color);
            border-radius: 6px;
            margin-right: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            background-color: white;
        }
 
        .cute-checkbox input[type="checkbox"]:checked + label .checkbox-custom {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
        }
 
        .cute-checkbox input[type="checkbox"]:checked + label .checkbox-custom::after {
            content: "&#10003;";
            color: white;
            font-size: 16px;
            font-weight: bold;
        }
 
        /* 气泡效果 */
        .bubble {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.6);
            animation: float 4s infinite ease-in-out;
            z-index: -1;
        }
 
        @keyframes float {
            0% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-20px) rotate(180deg); }
            100% { transform: translateY(0) rotate(360deg); }
        }
 
        /* 颜色选择器样式 */
        .color-picker {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 10px;
            justify-content: center;
        }
 
        .color-option {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid #ccc;
            transition: all 0.2s;
        }
 
        .color-option.selected {
            border: 2px solid var(--primary-color);
            transform: scale(1.1);
            box-shadow: 0 0 10px rgba(255, 133, 162, 0.4);
        }
 
        /* 预设模板选择器 */
        .templates {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
            margin-top: 15px;
            justify-content: center;
        }
 
        .template {
            width: 100px;
            height: 60px;
            border-radius: 10px;
            cursor: pointer;
            border: 2px solid #ccc;
            overflow: hidden;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            color: white;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
            background-size: cover;
            background-position: center;
        }
 
        .template:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
 
        .template.selected {
            border: 2px solid var(--primary-color);
            transform: scale(1.05);
            box-shadow: 0 5px 15px rgba(255, 133, 162, 0.3);
        }
 
        /* 提示气泡 */
        .tip-bubble {
            position: fixed;
            background-color: #FFF9C4;
            color: #5D4037;
            padding: 10px 15px;
            border-radius: 10px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
            font-size: 0.9rem;
            max-width: 250px;
            z-index: 100;
            animation: tipAppear 0.3s forwards;
            display: none;
            text-align: center;
        }
 
        .tip-bubble::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            border-width: 10px 10px 0;
            border-style: solid;
            border-color: #FFF9C4 transparent transparent;
        }
 
        @keyframes tipAppear {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
 
        /* 进度条样式 */
        .progress-container {
            width: 100%;
            height: 10px;
            background-color: #f0f0f0;
            border-radius: 5px;
            margin: 10px 0;
            overflow: hidden;
        }
 
        .progress-bar {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
            border-radius: 5px;
            transition: width 0.3s ease;
        }
 
        /* 主题切换按钮 */
        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            z-index: 10;
            transition: transform 0.3s ease;
        }
 
        .theme-toggle:hover {
            transform: rotate(30deg);
        }
 
        /* 暗色主题 */
        body.dark-theme {
            --primary-color: #FF85A2;
            --secondary-color: #FF5C8D;
            --accent-color: #7CB9E8;
            --text-color: #E0E0E0;
            --light-bg: #2D2D2D;
            --card-bg: #3D3D3D;
            --success-color: #66BB6A;
            --warning-color: #FFCA28;
            background-color: var(--light-bg);
        }
 
        body.dark-theme .container {
            background-color: var(--card-bg);
        }
 
        body.dark-theme .option-group {
            background-color: rgba(255, 133, 162, 0.1);
        }
 
        body.dark-theme .security-notice {
            background-color: rgba(102, 187, 106, 0.2);
            color: #A5D6A7;
        }
 
        /* 动画效果 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
 
        .fade-in {
            animation: fadeIn 0.5s forwards;
        }
 
        /* 水印预览 */
        .watermark-preview {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
            display: none;
        }
 
        /* 响应式设计增强 */
        [url=home.php?mod=space&uid=945662]@media[/url] (max-width: 768px) {
            .container {
                padding: 20px 15px;
                margin-top: 10px;
                border-radius: 12px;
            }
             
            h1 {
                font-size: 1.6rem;
                margin-bottom: 15px;
            }
             
            .emoji-title .emoji {
                font-size: 2rem;
            }
             
            .options-container {
                grid-template-columns: 1fr;
                gap: 15px;
            }
             
            .cute-button {
                padding: 10px 15px;
                font-size: 0.95rem;
                margin: 5px;
            }
             
            .upload-area {
                padding: 20px 15px;
            }
             
            .upload-icon {
                font-size: 2.5rem;
            }
             
            .upload-text {
                font-size: 1rem;
            }
             
            .templates {
                gap: 10px;
            }
             
            .template {
                width: 80px;
                height: 50px;
                font-size: 0.7rem;
            }
             
            .security-notice {
                padding: 10px;
                font-size: 0.85rem;
            }
             
            .theme-toggle {
                top: 10px;
                right: 10px;
                font-size: 1.3rem;
            }
             
            .color-picker {
                gap: 8px;
            }
             
            .color-option {
                width: 25px;
                height: 25px;
            }
             
            .cute-checkbox label {
                font-size: 0.9rem;
            }
             
            .cute-checkbox .checkbox-custom {
                width: 20px;
                height: 20px;
            }
        }
 
        @media (max-width: 480px) {
            body {
                padding: 10px;
            }
             
            .container {
                padding: 15px 10px;
            }
             
            h1 {
                font-size: 1.4rem;
            }
             
            .emoji-title .emoji {
                font-size: 1.8rem;
            }
             
            .button-container {
                flex-direction: column;
                align-items: center;
            }
             
            .cute-button {
                width: 100%;
                max-width: 250px;
            }
             
            .template {
                width: 70px;
                height: 45px;
                font-size: 0.65rem;
            }
             
            .option-label {
                font-size: 0.9rem;
            }
             
            .option-label .emoji {
                font-size: 1rem;
            }
             
            .footer {
                font-size: 0.8rem;
            }
             
            .bubble {
                display: none;
            }
        }
 
        /* 触摸设备优化 */
        @media (hover: none) {
            .cute-button:hover {
                transform: none;
                box-shadow: 0 4px 15px rgba(255, 133, 162, 0.3);
            }
             
            .option-group:hover {
                transform: none;
                border-color: var(--secondary-color);
            }
             
            .upload-area:hover {
                transform: none;
                border-color: var(--secondary-color);
                background-color: rgba(255, 240, 245, 0.5);
            }
             
            .template:hover {
                transform: none;
                box-shadow: none;
            }
             
            /* 添加触摸反馈 */
            .cute-button:active,
            .option-group:active,
            .upload-area:active,
            .template:active,
            .color-option:active {
                transform: scale(0.98);
            }
        }
 
        /* 打印样式 */
        @media print {
            body {
                background: none;
                padding: 0;
            }
             
            .container {
                box-shadow: none;
                padding: 0;
            }
             
            .button-container,
            .options-container,
            .upload-area,
            .theme-toggle,
            .bubble,
            .footer {
                display: none;
            }
             
            .canvas-container {
                box-shadow: none;
                background: none;
            }
             
            .security-notice {
                border: 1px solid #2E7D32;
                background: none;
                color: #2E7D32;
            }
        }
 
        /* 屏幕阅读器辅助 */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border-width: 0;
        }
 
        /* 加载动画增强 */
        .loading-text {
            position: absolute;
            bottom: -30px;
            font-size: 0.9rem;
            color: var(--primary-color);
            text-align: center;
            width: 100%;
        }
 
        /* 安全提示增强 */
        .security-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background-color: #2E7D32;
            color: white;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 0.8rem;
            margin-left: 5px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <!-- 屏幕阅读器辅助 -->
    <div class="sr-only">可爱身份证水印工具,用于在身份证照片上添加水印以保护个人信息安全</div>
 
    <!-- 装饰性气泡 -->
    <div class="bubble" style="width: 30px; height: 30px; top: 10%; left: 10%; animation-delay: 0s;"></div>
    <div class="bubble" style="width: 20px; height: 20px; top: 20%; left: 80%; animation-delay: 1s;"></div>
    <div class="bubble" style="width: 40px; height: 40px; top: 70%; left: 15%; animation-delay: 2s;"></div>
    <div class="bubble" style="width: 25px; height: 25px; top: 80%; left: 70%; animation-delay: 3s;"></div>
    <div class="bubble" style="width: 35px; height: 35px; top: 40%; left: 90%; animation-delay: 1.5s;"></div>
 
    <!-- 主题切换按钮 -->
    <button class="theme-toggle" id="theme-toggle" aria-label="切换主题颜色">&#127769;</button>
 
    <div class="container">
        <div class="emoji-title">
            <span class="emoji" role="img" aria-label="彩虹">&#127752;</span>
            <h1><span class="rainbow-text">可爱身份证水印工具</span></h1>
            <span class="emoji" role="img" aria-label="闪光">&#10024;</span>
        </div>
 
        <div class="upload-area" id="upload-area" role="button" aria-label="点击或拖放图片到这里">
            <div class="upload-icon" role="img" aria-hidden="true">&#128247;</div>
            <div class="upload-text">点击或拖放图片到这里</div>
            <div style="font-size: 0.9rem; color: #888;">支持 JPG, PNG, GIF 格式</div>
            <input type="file" id="upload" accept="image/*" class="file-input" aria-label="上传图片">
        </div>
 
        <div class="input-group">
            <input type="text" id="watermark-text" placeholder="输入水印文字 (例如: 仅用于办理XX业务)" class="cute-input" aria-label="水印文字">
            <div class="input-icon" role="img" aria-hidden="true">&#9999;&#65039;</div>
        </div>
 
        <!-- 预设模板选择 -->
        <div class="option-group" style="width: 100%;">
            <div class="option-label">
                <span class="emoji" role="img" aria-hidden="true">&#128221;</span> 快速选择常用水印文字
            </div>
            <div class="templates" role="radiogroup" aria-label="水印文字模板">
                <div class="template" style="background: linear-gradient(45deg, #FF5555, #FF8888);" data-text="仅用于XX银行办理业务" role="radio" aria-label="银行模板">
                    <span>&#127974; 银行</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #5555FF, #8888FF);" data-text="仅用于XX公司入职登记" role="radio" aria-label="入职模板">
                    <span>&#128188; 入职</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #55AA55, #88CC88);" data-text="仅用于XX学校注册登记" role="radio" aria-label="学校模板">
                    <span>&#127979; 学校</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #FFAA55, #FFCC88);" data-text="仅用于XX部门审核" role="radio" aria-label="审核模板">
                    <span>&#128203; 审核</span>
                </div>
            </div>
        </div>
 
        <div class="options-container">
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128292;</span> 文字大小
                </div>
                <select id="font-size" class="cute-select" aria-label="文字大小">
                    <option value="12">小 (12px)</option>
                    <option value="16">中 (16px)</option>
                    <option value="20" selected>大 (20px)</option>
                    <option value="24">超大 (24px)</option>
                    <option value="32">巨大 (32px)</option>
                </select>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128260;</span> 旋转角度
                </div>
                <input type="number" id="rotation" value="-45" step="5" min="-90" max="90" class="cute-number" aria-label="旋转角度">
                <div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.8rem;">
                    <span>↙&#65039; -90°</span>
                    <span>0°</span>
                    <span>90° ↗&#65039;</span>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128292;</span> 字体样式
                </div>
                <select id="font-family" class="cute-select" aria-label="字体样式">
                    <option value="Arial" selected>Arial</option>
                    <option value="'Nunito', sans-serif">Nunito</option>
                    <option value="'Comic Sans MS', cursive">Comic Sans</option>
                    <option value="'Times New Roman', serif">Times New Roman</option>
                    <option value="'Courier New', monospace">Courier New</option>
                </select>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128269;</span> 透明度
                </div>
                <input type="range" id="opacity" min="0" max="100" value="50" class="cute-range" aria-label="透明度">
                <div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.8rem;">
                    <span>透明 &#128123;</span>
                    <span>不透明 &#128269;</span>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#8596;&#65039;</span> 水平间距
                </div>
                <input type="number" id="horizontal-spacing" value="100" min="10" max="300" step="10" class="cute-number" aria-label="水平间距">
                <div class="progress-container">
                    <div class="progress-bar" id="horizontal-progress" style="width: 33%;" role="progressbar" aria-valuenow="33" aria-valuemin="0" aria-valuemax="100"></div>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#8597;&#65039;</span> 行间距
                </div>
                <input type="number" id="vertical-spacing" value="100" min="10" max="300" step="10" class="cute-number" aria-label="行间距">
                <div class="progress-container">
                    <div class="progress-bar" id="vertical-progress" style="width: 33%;" role="progressbar" aria-valuenow="33" aria-valuemin="0" aria-valuemax="100"></div>
                </div>
            </div>
        </div>
 
        <div class="option-group" style="width: 100%;">
            <div class="option-label">
                <span class="emoji" role="img" aria-hidden="true">&#127912;</span> 水印颜色
            </div>
            <div class="color-picker" role="radiogroup" aria-label="水印颜色选择">
                <div class="color-option selected" style="background-color: white;" data-color="white" role="radio" aria-label="白色" aria-checked="true"></div>
                <div class="color-option" style="background-color: black;" data-color="black" role="radio" aria-label="黑色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FF5555;" data-color="#FF5555" role="radio" aria-label="红色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #5555FF;" data-color="#5555FF" role="radio" aria-label="蓝色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #55AA55;" data-color="#55AA55" role="radio" aria-label="绿色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FF55FF;" data-color="#FF55FF" role="radio" aria-label="粉色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FFAA55;" data-color="#FFAA55" role="radio" aria-label="橙色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #55FFFF;" data-color="#55FFFF" role="radio" aria-label="青色" aria-checked="false"></div>
            </div>
        </div>
 
        <div class="cute-checkbox">
            <input type="checkbox" id="add-date" checked>
            <label for="add-date">
                <div class="checkbox-custom" aria-hidden="true"></div>
                <span>&#128197; 添加日期时间戳</span> <span style="color: var(--primary-color); margin-left: 5px;">(增加安全性)</span>
            </label>
        </div>
 
        <div class="cute-checkbox">
            <input type="checkbox" id="add-emoji" checked>
            <label for="add-emoji">
                <div class="checkbox-custom" aria-hidden="true"></div>
                <span>&#128522; 添加可爱表情</span> <span style="color: var(--primary-color); margin-left: 5px;">(增加趣味性)</span>
            </label>
        </div>
 
        <div class="button-container">
            <button id="preview-watermark" class="cute-button" style="background: linear-gradient(45deg, #9C27B0, #673AB7);" aria-label="预览水印效果">
                <span role="img" aria-hidden="true">&#128065;&#65039;</span> 预览水印
            </button>
            <button id="add-watermark" class="cute-button" aria-label="添加水印">
                <span role="img" aria-hidden="true">&#10024;</span> 添加水印 <span role="img" aria-hidden="true">&#10024;</span>
            </button>
            <button id="download" class="cute-button" style="display: none; background: linear-gradient(45deg, var(--success-color), var(--accent-color));" aria-label="下载图片">
                <span role="img" aria-hidden="true">&#128190;</span> 下载图片
            </button>
            <button id="reset" class="cute-button" style="background: linear-gradient(45deg, #888, #aaa);" aria-label="重置所有设置">
                <span role="img" aria-hidden="true">&#128260;</span> 重置
            </button>
        </div>
 
        <div class="canvas-container" aria-label="图片预览区域">
            <div class="loading" id="loading" aria-hidden="true">
                <div class="loading-spinner"></div>
                <div class="loading-text">处理中,请稍候... &#128049;</div>
            </div>
            <div class="watermark-preview" id="watermark-preview" aria-hidden="true"></div>
            <canvas id="canvas" width="337" height="213" aria-label="水印图片画布"></canvas>
        </div>
 
        <div class="security-notice" role="alert">
            <span style="font-size: 1.5rem;" role="img" aria-hidden="true">&#128274;</span>
            <div>
                <strong>安全提示:</strong>所有处理在您的浏览器中完成,图片不会上传到任何服务器
                <span class="security-badge">本地处理</span>
                <div class="tooltip">&#8505;&#65039;
                    <span class="tooltip-text">本工具完全在您的设备上运行,不会将您的身份证图片或个人信息发送到互联网上,保护您的隐私安全</span>
                </div>
            </div>
        </div>
    </div>
 
    <div class="footer" role="contentinfo">
        <div>使用 <span class="heart" role="img" aria-label="爱心">&#10084;&#65039;</span> 制作 | 保护您的个人信息安全</div>
        <div style="font-size: 0.8rem; margin-top: 5px;">&#128737;&#65039; 身份证等敏感证件添加水印可有效防止被盗用</div>
    </div>
 
    <!-- 提示气泡 -->
    <div class="tip-bubble" id="tip-bubble" role="status" aria-live="polite"></div>
 
    <script>
        let originalImage = null;
        let selectedColor = 'white';
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        const loading = document.getElementById('loading');
        const watermarkPreview = document.getElementById('watermark-preview');
        const tipBubble = document.getElementById('tip-bubble');
 
        // 检测设备类型
        const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
        if (isMobile) {
            document.body.classList.add('mobile-device');
        }
 
        // 主题切换
        const themeToggle = document.getElementById('theme-toggle');
        themeToggle.addEventListener('click', function() {
            document.body.classList.toggle('dark-theme');
            if (document.body.classList.contains('dark-theme')) {
                themeToggle.textContent = '&#9728;&#65039;';
                themeToggle.setAttribute('aria-label', '切换到亮色主题');
                showTip('已切换到暗色主题 &#127769;', themeToggle);
            } else {
                themeToggle.textContent = '&#127769;';
                themeToggle.setAttribute('aria-label', '切换到暗色主题');
                showTip('已切换到亮色主题 &#9728;&#65039;', themeToggle);
            }
        });
 
        // 显示提示气泡
        function showTip(message, element, duration = 2000) {
            const rect = element.getBoundingClientRect();
            tipBubble.textContent = message;
            tipBubble.style.display = 'block';
             
            // 移动设备上的位置调整
            if (isMobile) {
                tipBubble.style.top = '50%';
                tipBubble.style.left = '50%';
                tipBubble.style.transform = 'translate(-50%, -50%)';
            } else {
                tipBubble.style.top = (rect.top - 50) + 'px';
                tipBubble.style.left = (rect.left + rect.width / 2) + 'px';
                tipBubble.style.transform = 'translateX(-50%)';
            }
             
            setTimeout(() => {
                tipBubble.style.display = 'none';
            }, duration);
        }
 
        // 上传区域拖放功能
        const uploadArea = document.getElementById('upload-area');
        uploadArea.addEventListener('dragover', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--primary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.8)';
        });
 
        uploadArea.addEventListener('dragleave', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--secondary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.5)';
        });
 
        uploadArea.addEventListener('drop', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--secondary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.5)';
             
            if (e.dataTransfer.files.length) {
                document.getElementById('upload').files = e.dataTransfer.files;
                handleImageUpload(e.dataTransfer.files[0]);
            }
        });
 
        // 上传图片
        document.getElementById('upload').addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (!file) return;
            handleImageUpload(file);
        });
 
        function handleImageUpload(file) {
            if (!file.type.match('image.*')) {
                alert('请上传图片文件!');
                return;
            }
 
            loading.style.display = 'flex';
             
            const reader = new FileReader();
            reader.onload = function(event) {
                const img = new Image();
                img.onload = function() {
                    originalImage = img;
                     
                    // 调整canvas大小以适应图片
                    const maxWidth = 600;
                    const maxHeight = 400;
                    let width = img.width;
                    let height = img.height;
                     
                    if (width > maxWidth) {
                        height = (maxWidth / width) * height;
                        width = maxWidth;
                    }
                     
                    if (height > maxHeight) {
                        width = (maxHeight / height) * width;
                        height = maxHeight;
                    }
                     
                    canvas.width = width;
                    canvas.height = height;
                     
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    ctx.drawImage(img, 0, 0, width, height);
                    document.getElementById('download').style.display = 'none';
                    loading.style.display = 'none';
                     
                    showTip('图片上传成功!&#128077;', uploadArea);
                };
                img.src = event.target.result;
            };
            reader.readAsDataURL(file);
        }
 
        // 预设模板选择
        document.querySelectorAll('.template').forEach(template => {
            template.addEventListener('click', function() {
                document.querySelectorAll('.template').forEach(t => {
                    t.classList.remove('selected');
                    t.setAttribute('aria-checked', 'false');
                });
                this.classList.add('selected');
                this.setAttribute('aria-checked', 'true');
                document.getElementById('watermark-text').value = this.getAttribute('data-text');
                showTip('已选择模板:' + this.textContent.trim() + ' &#128221;', this);
            });
             
            // 键盘访问
            template.setAttribute('tabindex', '0');
            template.addEventListener('keydown', function(e) {
                if (e.key === 'Enter' || e.key === ' ') {
                    e.preventDefault();
                    this.click();
                }
            });
        });
 
        // 颜色选择器
        document.querySelectorAll('.color-option').forEach(option => {
            option.addEventListener('click', function() {
                document.querySelectorAll('.color-option').forEach(o => {
                    o.classList.remove('selected');
                    o.setAttribute('aria-checked', 'false');
                });
                this.classList.add('selected');
                this.setAttribute('aria-checked', 'true');
                selectedColor = this.getAttribute('data-color');
                showTip('已选择颜色 &#127912;', this);
            });
             
            // 键盘访问
            option.setAttribute('tabindex', '0');
            option.addEventListener('keydown', function(e) {
                if (e.key === 'Enter' || e.key === ' ') {
                    e.preventDefault();
                    this.click();
                }
            });
        });
 
        // 进度条更新
        document.getElementById('horizontal-spacing').addEventListener('input', function() {
            const value = this.value;
            const max = 300;
            const percentage = (value / max) * 100;
            const progressBar = document.getElementById('horizontal-progress');
            progressBar.style.width = percentage + '%';
            progressBar.setAttribute('aria-valuenow', Math.round(percentage));
        });
 
        document.getElementById('vertical-spacing').addEventListener('input', function() {
            const value = this.value;
            const max = 300;
            const percentage = (value / max) * 100;
            const progressBar = document.getElementById('vertical-progress');
            progressBar.style.width = percentage + '%';
            progressBar.setAttribute('aria-valuenow', Math.round(percentage));
        });
 
        // 预览水印
        document.getElementById('preview-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片!');
                return;
            }
             
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字!');
                return;
            }
             
            // 创建临时canvas来绘制水印
            const tempCanvas = document.createElement('canvas');
            tempCanvas.width = canvas.width;
            tempCanvas.height = canvas.height;
            const tempCtx = tempCanvas.getContext('2d');
             
            // 设置水印参数
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const addDate = document.getElementById('add-date').checked;
            const addEmoji = document.getElementById('add-emoji').checked;
             
            // 准备水印文字
            let watermarkText = text;
             
            // 添加日期时间戳
            if (addDate) {
                const now = new Date();
                const dateStr = now.toLocaleDateString();
                const timeStr = now.toLocaleTimeString();
                watermarkText += ` (${dateStr} ${timeStr})`;
            }
             
            // 添加表情
            if (addEmoji) {
                const emojis = ['&#128522;', '&#128077;', '&#9989;', '&#128274;', '&#11088;', '&#128175;'];
                const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
                watermarkText = randomEmoji + ' ' + watermarkText + ' ' + randomEmoji;
            }
             
            // 设置字体和样式
            tempCtx.font = `${fontSize}px ${fontFamily}`;
            tempCtx.fillStyle = selectedColor;
            tempCtx.globalAlpha = opacity;
            tempCtx.textBaseline = 'middle';
             
            // 保存当前状态
            tempCtx.save();
             
            // 移动到中心点并旋转
            tempCtx.translate(tempCanvas.width / 2, tempCanvas.height / 2);
            const angle = rotation * Math.PI / 180;
            tempCtx.rotate(angle);
             
            // 计算水印网格
            const textWidth = tempCtx.measureText(watermarkText).width;
            const diagonal = Math.sqrt(tempCanvas.width * tempCanvas.width + tempCanvas.height * tempCanvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
             
            // 绘制水印网格
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    tempCtx.fillText(watermarkText, x, y);
                }
            }
             
            // 恢复状态
            tempCtx.restore();
             
            // 显示预览
            watermarkPreview.style.display = 'block';
            watermarkPreview.style.backgroundImage = `url(${tempCanvas.toDataURL()})`;
             
            // 3秒后隐藏预览
            setTimeout(() => {
                watermarkPreview.style.display = 'none';
            }, 3000);
             
            showTip('预览水印效果(3秒后自动关闭)&#128065;&#65039;', this);
        });
 
        // 添加水印
        document.getElementById('add-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片!');
                return;
            }
             
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字!');
                return;
            }
             
            loading.style.display = 'flex';
             
            setTimeout(() => {
                applyWatermark();
                loading.style.display = 'none';
                showTip('水印添加成功!&#9989;', this);
            }, 500);
        });
 
        function applyWatermark() {
            const text = document.getElementById('watermark-text').value;
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const addDate = document.getElementById('add-date').checked;
            const addEmoji = document.getElementById('add-emoji').checked;
             
            // 重绘原始图片
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.drawImage(originalImage, 0, 0, canvas.width, canvas.height);
 
            // 设置水印文字
            let watermarkText = text;
             
            // 添加日期时间戳
            if (addDate) {
                const now = new Date();
                const dateStr = now.toLocaleDateString();
                const timeStr = now.toLocaleTimeString();
                watermarkText += ` (${dateStr} ${timeStr})`;
            }
             
            // 添加表情
            if (addEmoji) {
                const emojis = ['&#128522;', '&#128077;', '&#9989;', '&#128274;', '&#11088;', '&#128175;'];
                const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
                watermarkText = randomEmoji + ' ' + watermarkText + ' ' + randomEmoji;
            }
 
            // 设置字体
            ctx.font = `${fontSize}px ${fontFamily}`;
            ctx.fillStyle = selectedColor;
            ctx.globalAlpha = opacity;
            ctx.textBaseline = 'middle';
             
            // 保存当前状态
            ctx.save();
             
            // 移动到中心点并旋转
            ctx.translate(canvas.width / 2, canvas.height / 2);
            const angle = rotation * Math.PI / 180;
            ctx.rotate(angle);
             
            // 计算水印网格
            const textWidth = ctx.measureText(watermarkText).width;
            const diagonal = Math.sqrt(canvas.width * canvas.width + canvas.height * canvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
             
            // 绘制水印网格
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    ctx.fillText(watermarkText, x, y);
                }
            }
             
            // 恢复状态
            ctx.restore();
             
            // 重置透明度
            ctx.globalAlpha = 1.0;
             
            // 显示下载按钮
            document.getElementById('download').style.display = 'inline-block';
        }
 
        // 下载图片
        document.getElementById('download').addEventListener('click', function() {
            // 创建临时链接
            const link = document.createElement('a');
            link.download = '安全水印图片_' + new Date().getTime() + '.png';
             
            // 将canvas转换为blob
            canvas.toBlob(function(blob) {
                const url = URL.createObjectURL(blob);
                link.href = url;
                link.click();
                 
                // 清理
                setTimeout(() => {
                    URL.revokeObjectURL(url);
                }, 100);
                 
                showTip('图片已下载!&#128190;', document.getElementById('download'));
            });
        });
 
        // 重置按钮
        document.getElementById('reset').addEventListener('click', function() {
            if (originalImage) {
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.drawImage(originalImage, 0, 0, canvas.width, canvas.height);
                document.getElementById('download').style.display = 'none';
            }
             
            document.getElementById('watermark-text').value = '';
            document.getElementById('font-size').value = '20';
            document.getElementById('rotation').value = '-45';
            document.getElementById('font-family').value = 'Arial';
            document.getElementById('opacity').value = '50';
            document.getElementById('horizontal-spacing').value = '100';
            document.getElementById('vertical-spacing').value = '100';
            document.getElementById('add-date').checked = true;
            document.getElementById('add-emoji').checked = true;
             
            document.querySelectorAll('.template').forEach(t => {
                t.classList.remove('selected');
                t.setAttribute('aria-checked', 'false');
            });
             
            document.querySelectorAll('.color-option').forEach(o => {
                o.classList.remove('selected');
                o.setAttribute('aria-checked', 'false');
            });
            document.querySelector('.color-option[data-color="white"]').classList.add('selected');
            document.querySelector('.color-option[data-color="white"]').setAttribute('aria-checked', 'true');
            selectedColor = 'white';
             
            document.getElementById('horizontal-progress').style.width = '33%';
            document.getElementById('horizontal-progress').setAttribute('aria-valuenow', '33');
            document.getElementById('vertical-progress').style.width = '33%';
            document.getElementById('vertical-progress').setAttribute('aria-valuenow', '33');
             
            showTip('已重置所有设置!&#128260;', this);
        });
 
        // 初始化进度条
        document.getElementById('horizontal-progress').style.width = '33%';
        document.getElementById('vertical-progress').style.width = '33%';
 
        // 安全提示动画
        const securityNotice = document.querySelector('.security-notice');
        setTimeout(() => {
            securityNotice.style.backgroundColor = 'var(--warning-color)';
            setTimeout(() => {
                securityNotice.style.backgroundColor = 'var(--success-color)';
            }, 500);
        }, 2000);
 
        // 页面加载完成后显示欢迎提示
        window.addEventListener('load', function() {
            setTimeout(() => {
                showTip('欢迎使用可爱身份证水印工具!&#128522;', document.querySelector('.emoji-title'), 3000);
            }, 1000);
        });
 
        // 检测网络状态
        window.addEventListener('online', function() {
            showTip('网络已连接 &#127760;', document.body, 2000);
        });
 
        window.addEventListener('offline', function() {
            showTip('网络已断开,但不用担心,本工具可以离线使用 &#128268;', document.body, 3000);
        });
 
        // 添加键盘导航支持
        document.addEventListener('keydown', function(e) {
            // Esc键关闭预览
            if (e.key === 'Escape' && watermarkPreview.style.display === 'block') {
                watermarkPreview.style.display = 'none';
            }
        });
 
        // 添加触摸设备的双指缩放支持
        let initialPinchDistance = 0;
        let initialFontSize = 20;
 
        canvas.addEventListener('touchstart', function(e) {
            if (e.touches.length === 2) {
                initialPinchDistance = Math.hypot(
                    e.touches[0].clientX - e.touches[1].clientX,
                    e.touches[0].clientY - e.touches[1].clientY
                );
                initialFontSize = parseInt(document.getElementById('font-size').value);
            }
        });
 
        canvas.addEventListener('touchmove', function(e) {
            if (e.touches.length === 2) {
                e.preventDefault(); // 防止页面缩放
                 
                const currentDistance = Math.hypot(
                    e.touches[0].clientX - e.touches[1].clientX,
                    e.touches[0].clientY - e.touches[1].clientY
                );
                 
                const scaleFactor = currentDistance / initialPinchDistance;
                const newFontSize = Math.max(12, Math.min(32, Math.round(initialFontSize * scaleFactor)));
                 
                document.getElementById('font-size').value = newFontSize;
            }
        });
    </script>
</body>
</html>
zl33333 发表于 2025-3-24 16:27
[HTML] 纯文本查看 复制代码
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>&#127752;&#10024; 可爱身份证水印工具 &#10024;&#127752;</title>
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-color: #FF85A2;
            --secondary-color: #FFC2D1;
            --accent-color: #7CB9E8;
            --text-color: #5E5E5E;
            --light-bg: #FFF0F5;
            --card-bg: #FFFFFF;
            --success-color: #A0E7A0;
            --warning-color: #FFD700;
            --shadow: 0 8px 20px rgba(255, 133, 162, 0.2);
            --border-radius: 16px;
        }
 
        * {
            box-sizing: border-box;
            transition: all 0.3s ease;
        }
 
        body {
            font-family: 'Nunito', Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 0;
            padding: 20px;
            background-color: var(--light-bg);
            background-image:
                radial-gradient(circle at 10% 20%, rgba(255, 194, 209, 0.3) 0%, transparent 20%),
                radial-gradient(circle at 90% 30%, rgba(124, 185, 232, 0.3) 0%, transparent 20%),
                radial-gradient(circle at 50% 80%, rgba(160, 231, 160, 0.3) 0%, transparent 20%);
            color: var(--text-color);
            min-height: 100vh;
        }
 
        .container {
            background-color: var(--card-bg);
            padding: 30px;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            display: flex;
            flex-direction: column;
            align-items: center;
            max-width: 800px;
            width: 100%;
            margin-top: 20px;
            position: relative;
            overflow: hidden;
        }
 
        .container::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 8px;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
            border-radius: var(--border-radius) var(--border-radius) 0 0;
        }
 
        h1 {
            color: var(--primary-color);
            margin-bottom: 25px;
            text-align: center;
            font-weight: 700;
            font-size: 2.2rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
        }
 
        .emoji-title {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            flex-wrap: wrap;
        }
 
        .emoji-title .emoji {
            font-size: 2.5rem;
            animation: bounce 2s infinite alternate;
        }
 
        @keyframes bounce {
            0% { transform: translateY(0); }
            100% { transform: translateY(-10px); }
        }
 
        .upload-area {
            border: 3px dashed var(--secondary-color);
            border-radius: var(--border-radius);
            padding: 30px;
            text-align: center;
            width: 100%;
            margin-bottom: 20px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            background-color: rgba(255, 240, 245, 0.5);
        }
 
        .upload-area:hover {
            border-color: var(--primary-color);
            background-color: rgba(255, 240, 245, 0.8);
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(255, 133, 162, 0.3);
        }
 
        .upload-icon {
            font-size: 3rem;
            margin-bottom: 10px;
            color: var(--primary-color);
        }
 
        .upload-text {
            font-size: 1.2rem;
            color: var(--text-color);
            margin-bottom: 10px;
        }
 
        .file-input {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
        }
 
        .input-group {
            width: 100%;
            margin-bottom: 15px;
            position: relative;
        }
 
        .cute-input {
            width: 100%;
            padding: 12px 20px;
            border: 2px solid var(--secondary-color);
            border-radius: 25px;
            font-size: 1rem;
            color: var(--text-color);
            background-color: #FFFFFF;
            outline: none;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(255, 133, 162, 0.2);
        }
 
        .input-icon {
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--primary-color);
            font-size: 1.2rem;
        }
 
        .options-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            width: 100%;
            margin-bottom: 20px;
        }
 
        .option-group {
            display: flex;
            flex-direction: column;
            background-color: rgba(255, 240, 245, 0.5);
            padding: 15px;
            border-radius: var(--border-radius);
            border: 2px solid var(--secondary-color);
        }
 
        .option-group:hover {
            border-color: var(--primary-color);
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(255, 133, 162, 0.2);
        }
 
        .option-label {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
            font-weight: 600;
            color: var(--primary-color);
        }
 
        .option-label .emoji {
            margin-right: 8px;
            font-size: 1.2rem;
        }
 
        .cute-select, .cute-range, .cute-number {
            width: 100%;
            padding: 10px 15px;
            border: 2px solid var(--secondary-color);
            border-radius: 20px;
            font-size: 0.9rem;
            color: var(--text-color);
            background-color: #FFFFFF;
            outline: none;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-select:focus, .cute-range:focus, .cute-number:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(255, 133, 162, 0.2);
        }
 
        .cute-range {
            -webkit-appearance: none;
            height: 10px;
            background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
            border-radius: 5px;
            outline: none;
            padding: 0;
        }
 
        .cute-range::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--primary-color);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
        }
 
        .cute-range::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--primary-color);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
        }
 
        .cute-button {
            padding: 12px 25px;
            background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            box-shadow: 0 4px 15px rgba(255, 133, 162, 0.3);
            margin: 10px;
            transition: all 0.3s ease;
            font-family: 'Nunito', sans-serif;
        }
 
        .cute-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(255, 133, 162, 0.4);
        }
 
        .cute-button:active {
            transform: translateY(1px);
            box-shadow: 0 2px 10px rgba(255, 133, 162, 0.3);
        }
 
        .button-container {
            display: flex;
            justify-content: center;
            margin: 20px 0;
            flex-wrap: wrap;
            gap: 10px;
        }
 
        .canvas-container {
            position: relative;
            margin: 20px 0;
            border-radius: var(--border-radius);
            overflow: hidden;
            box-shadow: var(--shadow);
            background-color: #f0f0f0;
            background-image:
                linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
                linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
                linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
            background-size: 20px 20px;
            background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
            width: 100%;
            max-width: 600px;
        }
 
        #canvas {
            display: block;
            max-width: 100%;
            height: auto;
        }
 
        .security-notice {
            background-color: var(--success-color);
            color: #2E7D32;
            padding: 15px;
            border-radius: var(--border-radius);
            margin-top: 20px;
            text-align: center;
            font-size: 0.95rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            box-shadow: 0 4px 10px rgba(160, 231, 160, 0.3);
            flex-wrap: wrap;
        }
 
        .tooltip {
            position: relative;
            display: inline-block;
            margin-left: 5px;
            cursor: help;
        }
 
        .tooltip .tooltip-text {
            visibility: hidden;
            width: 220px;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 8px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 0.85rem;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        }
 
        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }
 
        .loading {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10;
            border-radius: var(--border-radius);
            display: none;
        }
 
        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 5px solid var(--secondary-color);
            border-top: 5px solid var(--primary-color);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
 
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
 
        .footer {
            margin-top: 30px;
            text-align: center;
            color: var(--text-color);
            font-size: 0.9rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }
 
        .heart {
            color: var(--primary-color);
            animation: heartbeat 1.5s infinite;
            font-size: 1.2rem;
        }
 
        @keyframes heartbeat {
            0% { transform: scale(1); }
            5% { transform: scale(1.2); }
            10% { transform: scale(1); }
            15% { transform: scale(1.2); }
            20% { transform: scale(1); }
            100% { transform: scale(1); }
        }
 
        /* 彩虹文字效果 */
        .rainbow-text {
            background-image: linear-gradient(90deg,
                #FF85A2, #FFA07A, #FFD700, #A0E7A0, #7CB9E8, #9370DB, #FF85A2);
            background-size: 600% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: rainbow 6s linear infinite;
        }
 
        @keyframes rainbow {
            0% { background-position: 0% 50%; }
            100% { background-position: 100% 50%; }
        }
 
        /* 可爱的复选框 */
        .cute-checkbox {
            display: flex;
            align-items: center;
            margin-top: 10px;
        }
 
        .cute-checkbox input[type="checkbox"] {
            display: none;
        }
 
        .cute-checkbox label {
            display: flex;
            align-items: center;
            cursor: pointer;
            user-select: none;
            color: var(--text-color);
        }
 
        .cute-checkbox .checkbox-custom {
            width: 24px;
            height: 24px;
            border: 2px solid var(--secondary-color);
            border-radius: 6px;
            margin-right: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            background-color: white;
        }
 
        .cute-checkbox input[type="checkbox"]:checked + label .checkbox-custom {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
        }
 
        .cute-checkbox input[type="checkbox"]:checked + label .checkbox-custom::after {
            content: "&#10003;";
            color: white;
            font-size: 16px;
            font-weight: bold;
        }
 
        /* 气泡效果 */
        .bubble {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.6);
            animation: float 4s infinite ease-in-out;
            z-index: -1;
        }
 
        @keyframes float {
            0% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-20px) rotate(180deg); }
            100% { transform: translateY(0) rotate(360deg); }
        }
 
        /* 颜色选择器样式 */
        .color-picker {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 10px;
            justify-content: center;
        }
 
        .color-option {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid #ccc;
            transition: all 0.2s;
        }
 
        .color-option.selected {
            border: 2px solid var(--primary-color);
            transform: scale(1.1);
            box-shadow: 0 0 10px rgba(255, 133, 162, 0.4);
        }
 
        /* 预设模板选择器 */
        .templates {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
            margin-top: 15px;
            justify-content: center;
        }
 
        .template {
            width: 100px;
            height: 60px;
            border-radius: 10px;
            cursor: pointer;
            border: 2px solid #ccc;
            overflow: hidden;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            color: white;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
            background-size: cover;
            background-position: center;
        }
 
        .template:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
 
        .template.selected {
            border: 2px solid var(--primary-color);
            transform: scale(1.05);
            box-shadow: 0 5px 15px rgba(255, 133, 162, 0.3);
        }
 
        /* 提示气泡 */
        .tip-bubble {
            position: fixed;
            background-color: #FFF9C4;
            color: #5D4037;
            padding: 10px 15px;
            border-radius: 10px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
            font-size: 0.9rem;
            max-width: 250px;
            z-index: 100;
            animation: tipAppear 0.3s forwards;
            display: none;
            text-align: center;
        }
 
        .tip-bubble::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            border-width: 10px 10px 0;
            border-style: solid;
            border-color: #FFF9C4 transparent transparent;
        }
 
        @keyframes tipAppear {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
 
        /* 进度条样式 */
        .progress-container {
            width: 100%;
            height: 10px;
            background-color: #f0f0f0;
            border-radius: 5px;
            margin: 10px 0;
            overflow: hidden;
        }
 
        .progress-bar {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
            border-radius: 5px;
            transition: width 0.3s ease;
        }
 
        /* 主题切换按钮 */
        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            z-index: 10;
            transition: transform 0.3s ease;
        }
 
        .theme-toggle:hover {
            transform: rotate(30deg);
        }
 
        /* 暗色主题 */
        body.dark-theme {
            --primary-color: #FF85A2;
            --secondary-color: #FF5C8D;
            --accent-color: #7CB9E8;
            --text-color: #E0E0E0;
            --light-bg: #2D2D2D;
            --card-bg: #3D3D3D;
            --success-color: #66BB6A;
            --warning-color: #FFCA28;
            background-color: var(--light-bg);
        }
 
        body.dark-theme .container {
            background-color: var(--card-bg);
        }
 
        body.dark-theme .option-group {
            background-color: rgba(255, 133, 162, 0.1);
        }
 
        body.dark-theme .security-notice {
            background-color: rgba(102, 187, 106, 0.2);
            color: #A5D6A7;
        }
 
        /* 动画效果 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
 
        .fade-in {
            animation: fadeIn 0.5s forwards;
        }
 
        /* 水印预览 */
        .watermark-preview {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
            display: none;
        }
 
        /* 分辨率调整部分 */
        .resolution-controls {
            display: flex;
            flex-direction: column;
            width: 100%;
            margin-top: 15px;
            background-color: rgba(255, 240, 245, 0.5);
            padding: 15px;
            border-radius: var(--border-radius);
            border: 2px solid var(--secondary-color);
        }
 
        .resolution-controls:hover {
            border-color: var(--primary-color);
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(255, 133, 162, 0.2);
        }
 
        .resolution-title {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
            font-weight: 600;
            color: var(--primary-color);
        }
 
        .resolution-title .emoji {
            margin-right: 8px;
            font-size: 1.2rem;
        }
 
        .resolution-inputs {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            align-items: center;
            justify-content: center;
        }
 
        .resolution-input-group {
            display: flex;
            flex-direction: column;
            width: 45%;
            min-width: 150px;
        }
 
        .resolution-input-group label {
            margin-bottom: 5px;
            font-size: 0.9rem;
            color: var(--text-color);
        }
 
        .resolution-info {
            margin-top: 10px;
            font-size: 0.85rem;
            color: var(--text-color);
            text-align: center;
        }
 
        .resolution-badge {
            display: inline-block;
            background-color: var(--accent-color);
            color: white;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 0.8rem;
            margin-left: 5px;
            font-weight: bold;
        }
 
        /* 响应式设计增强 */
        @media (max-width: 768px) {
            .container {
                padding: 20px 15px;
                margin-top: 10px;
                border-radius: 12px;
            }
             
            h1 {
                font-size: 1.6rem;
                margin-bottom: 15px;
            }
             
            .emoji-title .emoji {
                font-size: 2rem;
            }
             
            .options-container {
                grid-template-columns: 1fr;
                gap: 15px;
            }
             
            .cute-button {
                padding: 10px 15px;
                font-size: 0.95rem;
                margin: 5px;
            }
             
            .upload-area {
                padding: 20px 15px;
            }
             
            .upload-icon {
                font-size: 2.5rem;
            }
             
            .upload-text {
                font-size: 1rem;
            }
             
            .templates {
                gap: 10px;
            }
             
            .template {
                width: 80px;
                height: 50px;
                font-size: 0.7rem;
            }
             
            .security-notice {
                padding: 10px;
                font-size: 0.85rem;
            }
             
            .theme-toggle {
                top: 10px;
                right: 10px;
                font-size: 1.3rem;
            }
             
            .color-picker {
                gap: 8px;
            }
             
            .color-option {
                width: 25px;
                height: 25px;
            }
             
            .cute-checkbox label {
                font-size: 0.9rem;
            }
             
            .cute-checkbox .checkbox-custom {
                width: 20px;
                height: 20px;
            }
 
            .resolution-inputs {
                flex-direction: column;
                gap: 10px;
            }
 
            .resolution-input-group {
                width: 100%;
            }
        }
 
        @media (max-width: 480px) {
            body {
                padding: 10px;
            }
             
            .container {
                padding: 15px 10px;
            }
             
            h1 {
                font-size: 1.4rem;
            }
             
            .emoji-title .emoji {
                font-size: 1.8rem;
            }
             
            .button-container {
                flex-direction: column;
                align-items: center;
            }
             
            .cute-button {
                width: 100%;
                max-width: 250px;
            }
             
            .template {
                width: 70px;
                height: 45px;
                font-size: 0.65rem;
            }
             
            .option-label {
                font-size: 0.9rem;
            }
             
            .option-label .emoji {
                font-size: 1rem;
            }
             
            .footer {
                font-size: 0.8rem;
            }
             
            .bubble {
                display: none;
            }
        }
 
        /* 触摸设备优化 */
        @media (hover: none) {
            .cute-button:hover {
                transform: none;
                box-shadow: 0 4px 15px rgba(255, 133, 162, 0.3);
            }
             
            .option-group:hover {
                transform: none;
                border-color: var(--secondary-color);
            }
             
            .upload-area:hover {
                transform: none;
                border-color: var(--secondary-color);
                background-color: rgba(255, 240, 245, 0.5);
            }
             
            .template:hover {
                transform: none;
                box-shadow: none;
            }
             
            /* 添加触摸反馈 */
            .cute-button:active,
            .option-group:active,
            .upload-area:active,
            .template:active,
            .color-option:active {
                transform: scale(0.98);
            }
        }
 
        /* 打印样式 */
        @media print {
            body {
                background: none;
                padding: 0;
            }
             
            .container {
                box-shadow: none;
                padding: 0;
            }
             
            .button-container,
            .options-container,
            .upload-area,
            .theme-toggle,
            .bubble,
            .footer {
                display: none;
            }
             
            .canvas-container {
                box-shadow: none;
                background: none;
            }
             
            .security-notice {
                border: 1px solid #2E7D32;
                background: none;
                color: #2E7D32;
            }
        }
 
        /* 屏幕阅读器辅助 */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border-width: 0;
        }
 
        /* 加载动画增强 */
        .loading-text {
            position: absolute;
            bottom: -30px;
            font-size: 0.9rem;
            color: var(--primary-color);
            text-align: center;
            width: 100%;
        }
 
        /* 安全提示增强 */
        .security-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background-color: #2E7D32;
            color: white;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 0.8rem;
            margin-left: 5px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <!-- 屏幕阅读器辅助 -->
    <div class="sr-only">可爱身份证水印工具,用于在身份证照片上添加水印以保护个人信息安全</div>
 
    <!-- 装饰性气泡 -->
    <div class="bubble" style="width: 30px; height: 30px; top: 10%; left: 10%; animation-delay: 0s;"></div>
    <div class="bubble" style="width: 20px; height: 20px; top: 20%; left: 80%; animation-delay: 1s;"></div>
    <div class="bubble" style="width: 40px; height: 40px; top: 70%; left: 15%; animation-delay: 2s;"></div>
    <div class="bubble" style="width: 25px; height: 25px; top: 80%; left: 70%; animation-delay: 3s;"></div>
    <div class="bubble" style="width: 35px; height: 35px; top: 40%; left: 90%; animation-delay: 1.5s;"></div>
 
    <!-- 主题切换按钮 -->
    <button class="theme-toggle" id="theme-toggle" aria-label="切换主题颜色">&#127769;</button>
 
    <div class="container">
        <div class="emoji-title">
            <span class="emoji" role="img" aria-label="彩虹">&#127752;</span>
            <h1><span class="rainbow-text">可爱身份证水印工具</span></h1>
            <span class="emoji" role="img" aria-label="闪光">&#10024;</span>
        </div>
 
        <div class="upload-area" id="upload-area" role="button" aria-label="点击或拖放图片到这里">
            <div class="upload-icon" role="img" aria-hidden="true">&#128247;</div>
            <div class="upload-text">点击或拖放图片到这里</div>
            <div style="font-size: 0.9rem; color: #888;">支持 JPG, PNG, GIF 格式</div>
            <input type="file" id="upload" accept="image/*" class="file-input" aria-label="上传图片">
        </div>
 
        <div class="input-group">
            <input type="text" id="watermark-text" placeholder="输入水印文字 (例如: 仅用于办理XX业务)" class="cute-input" aria-label="水印文字">
            <div class="input-icon" role="img" aria-hidden="true">&#9999;&#65039;</div>
        </div>
 
        <!-- 预设模板选择 -->
        <div class="option-group" style="width: 100%;">
            <div class="option-label">
                <span class="emoji" role="img" aria-hidden="true">&#128221;</span> 快速选择常用水印文字
            </div>
            <div class="templates" role="radiogroup" aria-label="水印文字模板">
                <div class="template" style="background: linear-gradient(45deg, #FF5555, #FF8888);" data-text="仅用于XX银行办理业务" role="radio" aria-label="银行模板">
                    <span>&#127974; 银行</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #5555FF, #8888FF);" data-text="仅用于XX公司入职登记" role="radio" aria-label="入职模板">
                    <span>&#128188; 入职</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #55AA55, #88CC88);" data-text="仅用于XX学校注册登记" role="radio" aria-label="学校模板">
                    <span>&#127979; 学校</span>
                </div>
                <div class="template" style="background: linear-gradient(45deg, #FFAA55, #FFCC88);" data-text="仅用于XX部门审核" role="radio" aria-label="审核模板">
                    <span>&#128203; 审核</span>
                </div>
            </div>
        </div>
 
        <div class="options-container">
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128292;</span> 文字大小
                </div>
                <select id="font-size" class="cute-select" aria-label="文字大小">
                    <option value="12">小 (12px)</option>
                    <option value="16">中 (16px)</option>
                    <option value="20" selected>大 (20px)</option>
                    <option value="24">超大 (24px)</option>
                    <option value="32">巨大 (32px)</option>
                </select>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128260;</span> 旋转角度
                </div>
                <input type="number" id="rotation" value="-45" step="5" min="-90" max="90" class="cute-number" aria-label="旋转角度">
                <div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.8rem;">
                    <span>↙&#65039; -90°</span>
                    <span>0°</span>
                    <span>90° ↗&#65039;</span>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128292;</span> 字体样式
                </div>
                <select id="font-family" class="cute-select" aria-label="字体样式">
                    <option value="Arial" selected>Arial</option>
                    <option value="'Nunito', sans-serif">Nunito</option>
                    <option value="'Comic Sans MS', cursive">Comic Sans</option>
                    <option value="'Times New Roman', serif">Times New Roman</option>
                    <option value="'Courier New', monospace">Courier New</option>
                </select>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#128269;</span> 透明度
                </div>
                <input type="range" id="opacity" min="0" max="100" value="50" class="cute-range" aria-label="透明度">
                <div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.8rem;">
                    <span>透明 &#128123;</span>
                    <span>不透明 &#128269;</span>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#8596;&#65039;</span> 水平间距
                </div>
                <input type="number" id="horizontal-spacing" value="100" min="10" max="300" step="10" class="cute-number" aria-label="水平间距">
                <div class="progress-container">
                    <div class="progress-bar" id="horizontal-progress" style="width: 33%;" role="progressbar" aria-valuenow="33" aria-valuemin="0" aria-valuemax="100"></div>
                </div>
            </div>
 
            <div class="option-group">
                <div class="option-label">
                    <span class="emoji" role="img" aria-hidden="true">&#8597;&#65039;</span> 行间距
                </div>
                <input type="number" id="vertical-spacing" value="100" min="10" max="300" step="10" class="cute-number" aria-label="行间距">
                <div class="progress-container">
                    <div class="progress-bar" id="vertical-progress" style="width: 33%;" role="progressbar" aria-valuenow="33" aria-valuemin="0" aria-valuemax="100"></div>
                </div>
            </div>
        </div>
 
        <div class="option-group" style="width: 100%;">
            <div class="option-label">
                <span class="emoji" role="img" aria-hidden="true">&#127912;</span> 水印颜色
            </div>
            <div class="color-picker" role="radiogroup" aria-label="水印颜色选择">
                <div class="color-option selected" style="background-color: white;" data-color="white" role="radio" aria-label="白色" aria-checked="true"></div>
                <div class="color-option" style="background-color: black;" data-color="black" role="radio" aria-label="黑色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FF5555;" data-color="#FF5555" role="radio" aria-label="红色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #5555FF;" data-color="#5555FF" role="radio" aria-label="蓝色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #55AA55;" data-color="#55AA55" role="radio" aria-label="绿色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FF55FF;" data-color="#FF55FF" role="radio" aria-label="粉色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #FFAA55;" data-color="#FFAA55" role="radio" aria-label="橙色" aria-checked="false"></div>
                <div class="color-option" style="background-color: #55FFFF;" data-color="#55FFFF" role="radio" aria-label="青色" aria-checked="false"></div>
            </div>
        </div>
 
        <!-- 分辨率调整部分 -->
        <div class="resolution-controls">
            <div class="resolution-title">
                <span class="emoji" role="img" aria-hidden="true">&#128208;</span> 图片分辨率调整
            </div>
            <div class="resolution-inputs">
                <div class="resolution-input-group">
                    <label for="image-width">宽度 (像素) <span class="emoji" role="img" aria-hidden="true">&#8596;&#65039;</span></label>
                    <input type="number" id="image-width" class="cute-number" min="100" max="4000" step="10" value="1000" aria-label="图片宽度">
                </div>
                <div class="resolution-input-group">
                    <label for="image-height">高度 (像素) <span class="emoji" role="img" aria-hidden="true">&#8597;&#65039;</span></label>
                    <input type="number" id="image-height" class="cute-number" min="100" max="4000" step="10" value="600" aria-label="图片高度">
                </div>
            </div>
            <div class="cute-checkbox">
                <input type="checkbox" id="maintain-ratio" checked>
                <label for="maintain-ratio">
                    <div class="checkbox-custom" aria-hidden="true"></div>
                    <span>&#128274; 保持原始比例</span>
                </label>
            </div>
            <div class="resolution-info">
                当前分辨率: <span id="current-resolution">1000 × 600</span>
                <span class="resolution-badge" id="resolution-quality">高清</span>
            </div>
        </div>
 
        <div class="cute-checkbox">
            <input type="checkbox" id="add-date" checked>
            <label for="add-date">
                <div class="checkbox-custom" aria-hidden="true"></div>
                <span>&#128197; 添加日期时间戳</span> <span style="color: var(--primary-color); margin-left: 5px;">(增加安全性)</span>
            </label>
        </div>
 
        <div class="cute-checkbox">
            <input type="checkbox" id="add-emoji" checked>
            <label for="add-emoji">
                <div class="checkbox-custom" aria-hidden="true"></div>
                <span>&#128522; 添加可爱表情</span> <span style="color: var(--primary-color); margin-left: 5px;">(增加趣味性)</span>
            </label>
        </div>
 
        <div class="button-container">
            <button id="preview-watermark" class="cute-button" style="background: linear-gradient(45deg, #9C27B0, #673AB7);" aria-label="预览水印效果">
                <span role="img" aria-hidden="true">&#128065;&#65039;</span> 预览水印
            </button>
            <button id="add-watermark" class="cute-button" aria-label="添加水印">
                <span role="img" aria-hidden="true">&#10024;</span> 添加水印 <span role="img" aria-hidden="true">&#10024;</span>
            </button>
            <button id="download" class="cute-button" style="display: none; background: linear-gradient(45deg, var(--success-color), var(--accent-color));" aria-label="下载图片">
                <span role="img" aria-hidden="true">&#128190;</span> 下载图片
            </button>
            <button id="reset" class="cute-button" style="background: linear-gradient(45deg, #888, #aaa);" aria-label="重置所有设置">
                <span role="img" aria-hidden="true">&#128260;</span> 重置
            </button>
        </div>
 
        <div class="canvas-container" aria-label="图片预览区域">
            <div class="loading" id="loading" aria-hidden="true">
                <div class="loading-spinner"></div>
                <div class="loading-text">处理中,请稍候... &#128049;</div>
            </div>
            <div class="watermark-preview" id="watermark-preview" aria-hidden="true"></div>
            <canvas id="canvas" width="337" height="213" aria-label="水印图片画布"></canvas>
        </div>
 
        <div class="security-notice" role="alert">
            <span style="font-size: 1.5rem;" role="img" aria-hidden="true">&#128274;</span>
            <div>
                <strong>安全提示:</strong>所有处理在您的浏览器中完成,图片不会上传到任何服务器
                <span class="security-badge">本地处理</span>
                <div class="tooltip">&#8505;&#65039;
                    <span class="tooltip-text">本工具完全在您的设备上运行,不会将您的身份证图片或个人信息发送到互联网上,保护您的隐私安全</span>
                </div>
            </div>
        </div>
    </div>
 
    <div class="footer" role="contentinfo">
        <div>使用 <span class="heart" role="img" aria-label="爱心">&#10084;&#65039;</span> 制作 | 保护您的个人信息安全</div>
        <div style="font-size: 0.8rem; margin-top: 5px;">&#128737;&#65039; 身份证等敏感证件添加水印可有效防止被盗用</div>
    </div>
 
    <!-- 提示气泡 -->
    <div class="tip-bubble" id="tip-bubble" role="status" aria-live="polite"></div>
 
    <script>
        let originalImage = null;
        let selectedColor = 'white';
        let originalWidth = 0;
        let originalHeight = 0;
        let aspectRatio = 1;
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        const loading = document.getElementById('loading');
        const watermarkPreview = document.getElementById('watermark-preview');
        const tipBubble = document.getElementById('tip-bubble');
        const imageWidthInput = document.getElementById('image-width');
        const imageHeightInput = document.getElementById('image-height');
        const maintainRatioCheckbox = document.getElementById('maintain-ratio');
        const currentResolutionSpan = document.getElementById('current-resolution');
        const resolutionQualityBadge = document.getElementById('resolution-quality');
 
        // 检测设备类型
        const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
        if (isMobile) {
            document.body.classList.add('mobile-device');
        }
 
        // 主题切换
        const themeToggle = document.getElementById('theme-toggle');
        themeToggle.addEventListener('click', function() {
            document.body.classList.toggle('dark-theme');
            if (document.body.classList.contains('dark-theme')) {
                themeToggle.textContent = '&#9728;&#65039;';
                themeToggle.setAttribute('aria-label', '切换到亮色主题');
                showTip('已切换到暗色主题 &#127769;', themeToggle);
            } else {
                themeToggle.textContent = '&#127769;';
                themeToggle.setAttribute('aria-label', '切换到暗色主题');
                showTip('已切换到亮色主题 &#9728;&#65039;', themeToggle);
            }
        });
 
        // 显示提示气泡
        function showTip(message, element, duration = 2000) {
            const rect = element.getBoundingClientRect();
            tipBubble.textContent = message;
            tipBubble.style.display = 'block';
             
            // 移动设备上的位置调整
            if (isMobile) {
                tipBubble.style.top = '50%';
                tipBubble.style.left = '50%';
                tipBubble.style.transform = 'translate(-50%, -50%)';
            } else {
                tipBubble.style.top = (rect.top - 50) + 'px';
                tipBubble.style.left = (rect.left + rect.width / 2) + 'px';
                tipBubble.style.transform = 'translateX(-50%)';
            }
             
            setTimeout(() => {
                tipBubble.style.display = 'none';
            }, duration);
        }
 
        // 更新分辨率质量标签
        function updateResolutionQuality(width, height) {
            const pixels = width * height;
            let quality = '';
            let color = '';
             
            if (pixels < 300000) { // 小于0.3MP
                quality = '低清';
                color = '#FF5555';
            } else if (pixels < 1000000) { // 小于1MP
                quality = '标清';
                color = '#FFAA55';
            } else if (pixels < 2000000) { // 小于2MP
                quality = '高清';
                color = '#55AA55';
            } else if (pixels < 4000000) { // 小于4MP
                quality = '超清';
                color = '#5555FF';
            } else {
                quality = '超高清';
                color = '#AA55FF';
            }
             
            resolutionQualityBadge.textContent = quality;
            resolutionQualityBadge.style.backgroundColor = color;
            currentResolutionSpan.textContent = `${width} × ${height}`;
        }
 
        // 处理分辨率输入变化
        imageWidthInput.addEventListener('input', function() {
            const width = parseInt(this.value) || 1000;
            if (maintainRatioCheckbox.checked && aspectRatio) {
                const height = Math.round(width / aspectRatio);
                imageHeightInput.value = height;
                updateResolutionQuality(width, height);
            } else {
                const height = parseInt(imageHeightInput.value) || 600;
                updateResolutionQuality(width, height);
            }
        });
 
        imageHeightInput.addEventListener('input', function() {
            const height = parseInt(this.value) || 600;
            if (maintainRatioCheckbox.checked && aspectRatio) {
                const width = Math.round(height * aspectRatio);
                imageWidthInput.value = width;
                updateResolutionQuality(width, height);
            } else {
                const width = parseInt(imageWidthInput.value) || 1000;
                updateResolutionQuality(width, height);
            }
        });
 
        // 上传区域拖放功能
        const uploadArea = document.getElementById('upload-area');
        uploadArea.addEventListener('dragover', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--primary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.8)';
        });
 
        uploadArea.addEventListener('dragleave', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--secondary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.5)';
        });
 
        uploadArea.addEventListener('drop', function(e) {
            e.preventDefault();
            uploadArea.style.borderColor = 'var(--secondary-color)';
            uploadArea.style.backgroundColor = 'rgba(255, 240, 245, 0.5)';
             
            if (e.dataTransfer.files.length) {
                document.getElementById('upload').files = e.dataTransfer.files;
                handleImageUpload(e.dataTransfer.files[0]);
            }
        });
 
        // 上传图片
        document.getElementById('upload').addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (!file) return;
            handleImageUpload(file);
        });
 
        function handleImageUpload(file) {
            if (!file.type.match('image.*')) {
                alert('请上传图片文件!');
                return;
            }
 
            loading.style.display = 'flex';
             
            const reader = new FileReader();
            reader.onload = function(event) {
                const img = new Image();
                img.onload = function() {
                    originalImage = img;
                    originalWidth = img.width;
                    originalHeight = img.height;
                    aspectRatio = originalWidth / originalHeight;
                     
                    // 更新分辨率输入框
                    imageWidthInput.value = originalWidth;
                    imageHeightInput.value = originalHeight;
                    updateResolutionQuality(originalWidth, originalHeight);
                     
                    // 调整canvas大小以适应图片
                    const maxWidth = 600;
                    const maxHeight = 400;
                    let width = img.width;
                    let height = img.height;
                     
                    if (width > maxWidth) {
                        height = (maxWidth / width) * height;
                        width = maxWidth;
                    }
                     
                    if (height > maxHeight) {
                        width = (maxHeight / height) * width;
                        height = maxHeight;
                    }
                     
                    canvas.width = width;
                    canvas.height = height;
                     
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    ctx.drawImage(img, 0, 0, width, height);
                    document.getElementById('download').style.display = 'none';
                    loading.style.display = 'none';
                     
                    showTip('图片上传成功!&#128077;', uploadArea);
                };
                img.src = event.target.result;
            };
            reader.readAsDataURL(file);
        }
 
        // 预设模板选择
        document.querySelectorAll('.template').forEach(template => {
            template.addEventListener('click', function() {
                document.querySelectorAll('.template').forEach(t => {
                    t.classList.remove('selected');
                    t.setAttribute('aria-checked', 'false');
                });
                this.classList.add('selected');
                this.setAttribute('aria-checked', 'true');
                document.getElementById('watermark-text').value = this.getAttribute('data-text');
                showTip('已选择模板:' + this.textContent.trim() + ' &#128221;', this);
            });
             
            // 键盘访问
            template.setAttribute('tabindex', '0');
            template.addEventListener('keydown', function(e) {
                if (e.key === 'Enter' || e.key === ' ') {
                    e.preventDefault();
                    this.click();
                }
            });
        });
 
        // 颜色选择器
        document.querySelectorAll('.color-option').forEach(option => {
            option.addEventListener('click', function() {
                document.querySelectorAll('.color-option').forEach(o => {
                    o.classList.remove('selected');
                    o.setAttribute('aria-checked', 'false');
                });
                this.classList.add('selected');
                this.setAttribute('aria-checked', 'true');
                selectedColor = this.getAttribute('data-color');
                showTip('已选择颜色 &#127912;', this);
            });
             
            // 键盘访问
            option.setAttribute('tabindex', '0');
            option.addEventListener('keydown', function(e) {
                if (e.key === 'Enter' || e.key === ' ') {
                    e.preventDefault();
                    this.click();
                }
            });
        });
 
        // 进度条更新
        document.getElementById('horizontal-spacing').addEventListener('input', function() {
            const value = this.value;
            const max = 300;
            const percentage = (value / max) * 100;
            const progressBar = document.getElementById('horizontal-progress');
            progressBar.style.width = percentage + '%';
            progressBar.setAttribute('aria-valuenow', Math.round(percentage));
        });
 
        document.getElementById('vertical-spacing').addEventListener('input', function() {
            const value = this.value;
            const max = 300;
            const percentage = (value / max) * 100;
            const progressBar = document.getElementById('vertical-progress');
            progressBar.style.width = percentage + '%';
            progressBar.setAttribute('aria-valuenow', Math.round(percentage));
        });
 
        // 预览水印
        document.getElementById('preview-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片!');
                return;
            }
             
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字!');
                return;
            }
             
            // 创建临时canvas来绘制水印
            const tempCanvas = document.createElement('canvas');
            tempCanvas.width = canvas.width;
            tempCanvas.height = canvas.height;
            const tempCtx = tempCanvas.getContext('2d');
             
            // 设置水印参数
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const addDate = document.getElementById('add-date').checked;
            const addEmoji = document.getElementById('add-emoji').checked;
             
            // 准备水印文字
            let watermarkText = text;
             
            // 添加日期时间戳
            if (addDate) {
                const now = new Date();
                const dateStr = now.toLocaleDateString();
                const timeStr = now.toLocaleTimeString();
                watermarkText += ` (${dateStr} ${timeStr})`;
            }
             
            // 添加表情
            if (addEmoji) {
                const emojis = ['&#128522;', '&#128077;', '&#9989;', '&#128274;', '&#11088;', '&#128175;'];
                const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
                watermarkText = randomEmoji + ' ' + watermarkText + ' ' + randomEmoji;
            }
             
            // 设置字体和样式
            tempCtx.font = `${fontSize}px ${fontFamily}`;
            tempCtx.fillStyle = selectedColor;
            tempCtx.globalAlpha = opacity;
            tempCtx.textBaseline = 'middle';
             
            // 保存当前状态
            tempCtx.save();
             
            // 移动到中心点并旋转
            tempCtx.translate(tempCanvas.width / 2, tempCanvas.height / 2);
            const angle = rotation * Math.PI / 180;
            tempCtx.rotate(angle);
             
            // 计算水印网格
            const textWidth = tempCtx.measureText(watermarkText).width;
            const diagonal = Math.sqrt(tempCanvas.width * tempCanvas.width + tempCanvas.height * tempCanvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
             
            // 绘制水印网格
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    tempCtx.fillText(watermarkText, x, y);
                }
            }
             
            // 恢复状态
            tempCtx.restore();
             
            // 显示预览
            watermarkPreview.style.display = 'block';
            watermarkPreview.style.backgroundImage = `url(${tempCanvas.toDataURL()})`;
             
            // 3秒后隐藏预览
            setTimeout(() => {
                watermarkPreview.style.display = 'none';
            }, 3000);
             
            showTip('预览水印效果(3秒后自动关闭)&#128065;&#65039;', this);
        });
 
        // 添加水印
        document.getElementById('add-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片!');
                return;
            }
             
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字!');
                return;
            }
             
            loading.style.display = 'flex';
             
            setTimeout(() => {
                applyWatermark();
                loading.style.display = 'none';
                showTip('水印添加成功!&#9989;', this);
            }, 500);
        });
 
        function applyWatermark() {
            const text = document.getElementById('watermark-text').value;
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const addDate = document.getElementById('add-date').checked;
            const addEmoji = document.getElementById('add-emoji').checked;
             
            // 重绘原始图片
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.drawImage(originalImage, 0, 0, canvas.width, canvas.height);
 
            // 设置水印文字
            let watermarkText = text;
             
            // 添加日期时间戳
            if (addDate) {
                const now = new Date();
                const dateStr = now.toLocaleDateString();
                const timeStr = now.toLocaleTimeString();
                watermarkText += ` (${dateStr} ${timeStr})`;
            }
             
            // 添加表情
            if (addEmoji) {
                const emojis = ['&#128522;', '&#128077;', '&#9989;', '&#128274;', '&#11088;', '&#128175;'];
                const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
                watermarkText = randomEmoji + ' ' + watermarkText + ' ' + randomEmoji;
            }
 
            // 设置字体
            ctx.font = `${fontSize}px ${fontFamily}`;
            ctx.fillStyle = selectedColor;
            ctx.globalAlpha = opacity;
            ctx.textBaseline = 'middle';
             
            // 保存当前状态
            ctx.save();
             
            // 移动到中心点并旋转
            ctx.translate(canvas.width / 2, canvas.height / 2);
            const angle = rotation * Math.PI / 180;
            ctx.rotate(angle);
             
            // 计算水印网格
            const textWidth = ctx.measureText(watermarkText).width;
            const diagonal = Math.sqrt(canvas.width * canvas.width + canvas.height * canvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
             
            // 绘制水印网格
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    ctx.fillText(watermarkText, x, y);
                }
            }
             
            // 恢复状态
            ctx.restore();
             
            // 重置透明度
            ctx.globalAlpha = 1.0;
             
            // 显示下载按钮
            document.getElementById('download').style.display = 'inline-block';
        }
 
        // 下载图片
        document.getElementById('download').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片!');
                return;
            }
             
            loading.style.display = 'flex';
             
            setTimeout(() => {
                // 获取用户设置的分辨率
                const targetWidth = parseInt(imageWidthInput.value) || originalWidth;
                const targetHeight = parseInt(imageHeightInput.value) || originalHeight;
                 
                // 创建一个新的canvas用于导出高分辨率图片
                const exportCanvas = document.createElement('canvas');
                exportCanvas.width = targetWidth;
                exportCanvas.height = targetHeight;
                const exportCtx = exportCanvas.getContext('2d');
                 
                // 绘制原始图片
                exportCtx.drawImage(originalImage, 0, 0, targetWidth, targetHeight);
                 
                // 设置水印参数
                const text = document.getElementById('watermark-text').value;
                const fontSize = parseInt(document.getElementById('font-size').value);
                const rotation = parseFloat(document.getElementById('rotation').value);
                const fontFamily = document.getElementById('font-family').value;
                const opacity = parseInt(document.getElementById('opacity').value) / 100;
                const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
                const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
                const addDate = document.getElementById('add-date').checked;
                const addEmoji = document.getElementById('add-emoji').checked;
                 
                // 计算字体大小比例
                const scaleFactor = Math.max(targetWidth / canvas.width, targetHeight / canvas.height);
                const scaledFontSize = Math.round(fontSize * scaleFactor);
                 
                // 设置水印文字
                let watermarkText = text;
                 
                // 添加日期时间戳
                if (addDate) {
                    const now = new Date();
                    const dateStr = now.toLocaleDateString();
                    const timeStr = now.toLocaleTimeString();
                    watermarkText += ` (${dateStr} ${timeStr})`;
                }
                 
                // 添加表情
                if (addEmoji) {
                    const emojis = ['&#128522;', '&#128077;', '&#9989;', '&#128274;', '&#11088;', '&#128175;'];
                    const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
                    watermarkText = randomEmoji + ' ' + watermarkText + ' ' + randomEmoji;
                }
                 
                // 设置字体和样式
                exportCtx.font = `${scaledFontSize}px ${fontFamily}`;
                exportCtx.fillStyle = selectedColor;
                exportCtx.globalAlpha = opacity;
                exportCtx.textBaseline = 'middle';
                 
                // 保存当前状态
                exportCtx.save();
                 
                // 移动到中心点并旋转
                exportCtx.translate(exportCanvas.width / 2, exportCanvas.height / 2);
                const angle = rotation * Math.PI / 180;
                exportCtx.rotate(angle);
                 
                // 计算水印网格
                const textWidth = exportCtx.measureText(watermarkText).width;
                const diagonal = Math.sqrt(exportCanvas.width * exportCanvas.width + exportCanvas.height * exportCanvas.height);
                const scaledHorizontalSpacing = horizontalSpacing * scaleFactor;
                const scaledVerticalSpacing = verticalSpacing * scaleFactor;
                const cols = Math.ceil(diagonal / (textWidth + scaledHorizontalSpacing));
                const rows = Math.ceil(diagonal / scaledVerticalSpacing);
                 
                // 绘制水印网格
                for (let i = -rows; i < rows; i++) {
                    for (let j = -cols; j < cols; j++) {
                        const x = j * (textWidth + scaledHorizontalSpacing);
                        const y = i * scaledVerticalSpacing;
                        exportCtx.fillText(watermarkText, x, y);
                    }
                }
                 
                // 恢复状态
                exportCtx.restore();
                 
                // 创建临时链接
                const link = document.createElement('a');
                link.download = '安全水印图片_' + new Date().getTime() + '.png';
                 
                // 将canvas转换为blob
                exportCanvas.toBlob(function(blob) {
                    const url = URL.createObjectURL(blob);
                    link.href = url;
                    link.click();
                     
                    // 清理
                    setTimeout(() => {
                        URL.revokeObjectURL(url);
                        loading.style.display = 'none';
                    }, 100);
                     
                    showTip(`已下载 ${targetWidth}×${targetHeight} 分辨率图片!&#128190;`, document.getElementById('download'));
                });
            }, 500);
        });
 
        // 重置按钮
        document.getElementById('reset').addEventListener('click', function() {
            if (originalImage) {
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.drawImage(originalImage, 0, 0, canvas.width, canvas.height);
                document.getElementById('download').style.display = 'none';
                 
                // 重置分辨率设置
                if (originalWidth && originalHeight) {
                    imageWidthInput.value = originalWidth;
                    imageHeightInput.value = originalHeight;
                    updateResolutionQuality(originalWidth, originalHeight);
                }
            }
             
            document.getElementById('watermark-text').value = '';
            document.getElementById('font-size').value = '20';
            document.getElementById('rotation').value = '-45';
            document.getElementById('font-family').value = 'Arial';
            document.getElementById('opacity').value = '50';
            document.getElementById('horizontal-spacing').value = '100';
            document.getElementById('vertical-spacing').value = '100';
            document.getElementById('add-date').checked = true;
            document.getElementById('add-emoji').checked = true;
            document.getElementById('maintain-ratio').checked = true;
             
            document.querySelectorAll('.template').forEach(t => {
                t.classList.remove('selected');
                t.setAttribute('aria-checked', 'false');
            });
             
            document.querySelectorAll('.color-option').forEach(o => {
                o.classList.remove('selected');
                o.setAttribute('aria-checked', 'false');
            });
            document.querySelector('.color-option[data-color="white"]').classList.add('selected');
            document.querySelector('.color-option[data-color="white"]').setAttribute('aria-checked', 'true');
            selectedColor = 'white';
             
            document.getElementById('horizontal-progress').style.width = '33%';
            document.getElementById('horizontal-progress').setAttribute('aria-valuenow', '33');
            document.getElementById('vertical-progress').style.width = '33%';
            document.getElementById('vertical-progress').setAttribute('aria-valuenow', '33');
             
            showTip('已重置所有设置!&#128260;', this);
        });
 
        // 初始化进度条
        document.getElementById('horizontal-progress').style.width = '33%';
        document.getElementById('vertical-progress').style.width = '33%';
 
        // 安全提示动画
        const securityNotice = document.querySelector('.security-notice');
        setTimeout(() => {
            securityNotice.style.backgroundColor = 'var(--warning-color)';
            setTimeout(() => {
                securityNotice.style.backgroundColor = 'var(--success-color)';
            }, 500);
        }, 2000);
 
        // 页面加载完成后显示欢迎提示
        window.addEventListener('load', function() {
            setTimeout(() => {
                showTip('欢迎使用可爱身份证水印工具!&#128522;', document.querySelector('.emoji-title'), 3000);
            }, 1000);
        });
 
        // 检测网络状态
        window.addEventListener('online', function() {
            showTip('网络已连接 &#127760;', document.body, 2000);
        });
 
        window.addEventListener('offline', function() {
            showTip('网络已断开,但不用担心,本工具可以离线使用 &#128268;', document.body, 3000);
        });
 
        // 添加键盘导航支持
        document.addEventListener('keydown', function(e) {
            // Esc键关闭预览
            if (e.key === 'Escape' && watermarkPreview.style.display === 'block') {
                watermarkPreview.style.display = 'none';
            }
        });
 
        // 添加触摸设备的双指缩放支持
        let initialPinchDistance = 0;
        let initialFontSize = 20;
 
        canvas.addEventListener('touchstart', function(e) {
            if (e.touches.length === 2) {
                initialPinchDistance = Math.hypot(
                    e.touches[0].clientX - e.touches[1].clientX,
                    e.touches[0].clientY - e.touches[1].clientY
                );
                initialFontSize = parseInt(document.getElementById('font-size').value);
            }
        });
 
        canvas.addEventListener('touchmove', function(e) {
            if (e.touches.length === 2) {
                e.preventDefault(); // 防止页面缩放
                 
                const currentDistance = Math.hypot(
                    e.touches[0].clientX - e.touches[1].clientX,
                    e.touches[0].clientY - e.touches[1].clientY
                );
                 
                const scaleFactor = currentDistance / initialPinchDistance;
                const newFontSize = Math.max(12, Math.min(32, Math.round(initialFontSize * scaleFactor)));
                 
                document.getElementById('font-size').value = newFontSize;
            }
        });
    </script>
</body>
</html>



可自由调节分辨率
whtaoo 发表于 2025-3-24 15:11
cxg2773 发表于 2025-3-24 15:20
测试了,确实很不错
HUANGyanfeng139 发表于 2025-3-24 15:21
学习学习
sohuso 发表于 2025-3-24 15:22
挺方便的,建议增加个字体颜色功能
JJarvis 发表于 2025-3-24 15:27
测试好用
sohuso 发表于 2025-3-24 15:32
本帖最后由 sohuso 于 2025-3-24 15:34 编辑

在原先基础上增加了颜色选择功能
[Asm] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>身份证水印工具</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 20px;
            background-color: #f0f0f0;
        }
        h1 {
            color: #333;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        input[type="file"], input[type="text"], select, input[type="number"], input[type="range"], input[type="color"] {
            margin: 10px 0;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            width: 300px;
        }
        button {
            margin: 10px;
            padding: 10px 20px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        #canvas {
            margin-top: 20px;
            border: 1px solid #ccc;
            box-shadow: 0 0 5px rgba(0,0,0,0.2);
        }
        .options {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
            width: 100%;
        }
        .option-group {
            margin: 10px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>身份证水印工具</h1>
        <input type="file" id="upload" accept="image/*">
        <input type="text" id="watermark-text" placeholder="输入水印文字">
        <div class="options">
            <div class="option-group">
                <label for="font-size">文字大小:</label>
                <select id="font-size">
                    <option value="12">12px</option>
                    <option value="16">16px</option>
                    <option value="20" selected>20px</option>
                    <option value="24">24px</option>
                </select>
            </div>
            <div class="option-group">
                <label for="rotation">旋转角度(度):</label>
                <input type="number" id="rotation" value="-45" step="1">
            </div>
            <div class="option-group">
                <label for="font-family">字体:</label>
                <select id="font-family">
                    <option value="Arial" selected>Arial</option>
                    <option value="Times New Roman">Times New Roman</option>
                    <option value="Courier New">Courier New</option>
                    <option value="Verdana">Verdana</option>
                </select>
            </div>
            <div class="option-group">
                <label for="opacity">透明度(0-100):</label>
                <input type="range" id="opacity" min="0" max="100" value="50">
            </div>
            <div class="option-group">
                <label for="horizontal-spacing">水平间距(像素):</label>
                <input type="number" id="horizontal-spacing" value="50" min="10" step="10">
            </div>
            <div class="option-group">
                <label for="vertical-spacing">行间距(像素):</label>
                <input type="number" id="vertical-spacing" value="100" min="10" step="10">
            </div>
            <div class="option-group">
                <label for="font-color">字体颜色:</label>
                <input type="color" id="font-color" value="#FFFFFF">
            </div>
        </div>
        <button id="add-watermark">添加水印</button>
        <canvas id="canvas" width="337" height="213"></canvas>
        <button id="download" style="display: none;">下载图片</button>
    </div>
 
    <script>
        let originalImage = null;
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
 
        // 上传图片
        document.getElementById('upload').addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (!file) return;
 
            const reader = new FileReader();
            reader.onload = function(event) {
                const img = new Image();
                img.onload = function() {
                    originalImage = img;
                    const scale = Math.min(canvas.width / img.width, canvas.height / img.height);
                    const width = img.width * scale;
                    const height = img.height * scale;
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    ctx.drawImage(img, (canvas.width - width) / 2, (canvas.height - height) / 2, width, height);
                    document.getElementById('download').style.display = 'none';
                };
                img.src = event.target.result;
            };
            reader.readAsDataURL(file);
        });
 
        // 添加水印
        document.getElementById('add-watermark').addEventListener('click', function() {
            if (!originalImage) {
                alert('请先上传图片');
                return;
            }
            const text = document.getElementById('watermark-text').value;
            if (!text) {
                alert('请输入水印文字');
                return;
            }
            const fontSize = document.getElementById('font-size').value;
            const rotation = parseFloat(document.getElementById('rotation').value);
            const fontFamily = document.getElementById('font-family').value;
            const opacity = parseInt(document.getElementById('opacity').value) / 100;
            const horizontalSpacing = parseInt(document.getElementById('horizontal-spacing').value);
            const verticalSpacing = parseInt(document.getElementById('vertical-spacing').value);
            const fontColor = document.getElementById('font-color').value;
 
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            const scale = Math.min(canvas.width / originalImage.width, canvas.height / originalImage.height);
            const width = originalImage.width * scale;
            const height = originalImage.height * scale;
            ctx.drawImage(originalImage, (canvas.width - width) / 2, (canvas.height - height) / 2, width, height);
 
            ctx.font = `${fontSize}px ${fontFamily}`;
            ctx.fillStyle = `rgba(${parseInt(fontColor.slice(1, 3), 16)}, ${parseInt(fontColor.slice(3, 5), 16)}, ${parseInt(fontColor.slice(5, 7), 16)}, ${opacity})`;
            ctx.textBaseline = 'middle';
            ctx.save();
            ctx.translate(canvas.width / 2, canvas.height / 2);
            const angle = rotation * Math.PI / 180;
            ctx.rotate(angle);
            const textWidth = ctx.measureText(text).width;
            const diagonal = Math.sqrt(canvas.width * canvas.width + canvas.height * canvas.height);
            const cols = Math.ceil(diagonal / (textWidth + horizontalSpacing));
            const rows = Math.ceil(diagonal / verticalSpacing);
            for (let i = -rows; i < rows; i++) {
                for (let j = -cols; j < cols; j++) {
                    const x = j * (textWidth + horizontalSpacing);
                    const y = i * verticalSpacing;
                    ctx.fillText(text, x, y);
                }
            }
            ctx.restore();
            document.getElementById('download').style.display = 'inline-block';
        });
 
        // 下载图片
        document.getElementById('download').addEventListener('click', function() {
            const dataURL = canvas.toDataURL('image/png');
            const a = document.createElement('a');
            a.href = dataURL;
            a.download = 'watermarked-image.png';
            a.click();
        });
    </script>
</body>
</html>
kikyoulin 发表于 2025-3-24 15:37
存储来的图片,分辨率太低了,很模糊
wgsls 发表于 2025-3-24 15:44
我保存源码后文,件不能正常使用怎么回事(wids7系统)
hunterxie 发表于 2025-3-24 15:45
这个很使用啊,不用每次去ps了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-23 21:03

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表