开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 536|回复: 7
收起左侧

[易语言] svg转png

[复制链接]
结帖率:0% (0/1)
发表于 2025-9-22 13:28:56 | 显示全部楼层 |阅读模式   广东省广州市
15精币
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 300 260" class="geetest_svg_container geetest_svg_container_hash">
        <style>
            .geetest_frame_hash { opacity: 0; }

            @-webkit-keyframes geetest_frame1_animation_hash {
                0% { opacity: 0; }
                0.01% { opacity: 1; }
                28.63% { opacity: 1; }
                28.64% { opacity: 0; }
                100% { opacity: 0; }
            }

            @keyframes geetest_frame1_animation_hash {
                0% { opacity: 0; }
                0.01% { opacity: 1; }
                28.63% { opacity: 1; }
                28.64% { opacity: 0; }
                100% { opacity: 0; }
            }

            @-webkit-keyframes geetest_frame2_animation_hash {
                0% { opacity: 0; }
                28.63% { opacity: 0; }
                28.64% { opacity: 1; }
                63.97% { opacity: 1; }
                63.98% { opacity: 0; }
                100% { opacity: 0; }
            }

            @keyframes geetest_frame2_animation_hash {
                0% { opacity: 0; }
                28.63% { opacity: 0; }
                28.64% { opacity: 1; }
                63.97% { opacity: 1; }
                63.98% { opacity: 0; }
                100% { opacity: 0; }
            }

            @-webkit-keyframes geetest_frame3_animation_hash {
                0% { opacity: 0; }
                63.97% { opacity: 0; }
                63.98% { opacity: 1; }
                100% { opacity: 1; }
            }

            @keyframes geetest_frame3_animation_hash {
                0% { opacity: 0; }
                63.97% { opacity: 0; }
                63.98% { opacity: 1; }
                100% { opacity: 1; }
            }

            .geetest_frame_1_hash.geetest_frame_active_hash {
                -webkit-animation: geetest_frame1_animation_hash 5.906s infinite steps(1);
                animation: geetest_frame1_animation_hash 5.906s infinite steps(1);
            }

            .geetest_frame_2_hash.geetest_frame_active_hash {
                -webkit-animation: geetest_frame2_animation_hash 5.906s infinite steps(1);
                animation: geetest_frame2_animation_hash 5.906s infinite steps(1);
            }

            .geetest_frame_3_hash.geetest_frame_active_hash {
                -webkit-animation: geetest_frame3_animation_hash 5.906s infinite steps(1);
                animation: geetest_frame3_animation_hash 5.906s infinite steps(1);
            }
            .geetest_svg_container_hash rect, .geetest_svg_container_hash path {
                fill: none;
            }
        </style>
        <rect width="100%" height="100%" style="fill: none;"/><g class="geetest_frame_hash geetest_frame_1_hash geetest_frame_active_hash"><rect class="geetest_grid_hash" x="0" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,62.5) scale(0.8) translate(-24,-24)"><circle cx="10" cy="24" r="4" style="fill: #000;" stroke="#333" stroke-width="4"/><circle cx="38" cy="10" r="4" style="fill: #000;" stroke="#333" stroke-width="4"/><circle cx="38" cy="24" r="4" style="fill: #000;" stroke="#333" stroke-width="4"/><circle cx="38" cy="38" r="4" style="fill: #000;" stroke="#333" stroke-width="4"/><path d="M34 38L22 38V10H34" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M14 24L34 24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,62.5) scale(0.8) translate(-24,-24)"><path d="M24 31L24 35C24 39 21 42 17 42C13 42 10 39 10 35L10 16" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M38 42L38 13C38 8.99999 35 5.99999 31 5.99999C27 5.99999 24 8.99999 24 13L24 31" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 37L38 42L43 37" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="10" cy="10.9999" r="5" transform="rotate(-180 10 10.9999)" style="fill: #000;" stroke="#333" stroke-width="4"/></g><rect class="geetest_grid_hash" x="0" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,197.5) scale(0.8) translate(-24,-24)"><rect x="4" y="30" width="8" height="8" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><rect x="36" y="30" width="8" height="8" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><rect x="20" y="10" width="8" height="8" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M20 14H4" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M44 14H28" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 30.0001C8 22.5447 13.0991 16.2803 20 14.5042" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M28 14.5042C34.9009 16.2803 40 22.5447 40 30.0001" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,197.5) scale(0.8) translate(-24,-24)"><path d="M5 24L43 24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M28 4H20C18.8954 4 18 4.89543 18 6V14C18 15.1046 18.8954 16 20 16H28C29.1046 16 30 15.1046 30 14V6C30 4.89543 29.1046 4 28 4Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M16 32H8C6.89543 32 6 32.8954 6 34V42C6 43.1046 6.89543 44 8 44H16C17.1046 44 18 43.1046 18 42V34C18 32.8954 17.1046 32 16 32Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M40 32H32C30.8954 32 30 32.8954 30 34V42C30 43.1046 30.8954 44 32 44H40C41.1046 44 42 43.1046 42 42V34C42 32.8954 41.1046 32 40 32Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M24 24V16" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M36 32V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 32V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g></g><g class="geetest_frame_hash geetest_frame_2_hash geetest_frame_active_hash"><rect class="geetest_grid_hash" x="0" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,62.5) scale(0.8) translate(-24,-24)"><rect x="10" y="6" width="28" height="36" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M20.643 23.8886C22.0743 22.0081 23.1776 19.4103 23.774 18C24.8177 19.4103 27.084 22.9484 27.7997 24.8288C28.6942 27.1793 26.4578 30 23.774 30C21.0903 30 18.8538 26.2391 20.643 23.8886Z" style="fill: #000;" stroke="#FFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 6H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 42H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 24H10" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M38 24H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,62.5) scale(0.8) translate(-24,-24)"><path d="M20 14L16 12L24 4L32 12L28 14L36 22L30 24L39 34H9L17 24L12 22L20 14Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M31 44H17" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M21 34L20 44" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M27 34L28 44" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="0" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,197.5) scale(0.8) translate(-24,-24)"><rect x="6" y="6" width="36" height="36" rx="3" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M16 6V42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M32 6V42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 15H16" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M32 15H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 33H16" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 24H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M32 33H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,197.5) scale(0.8) translate(-24,-24)"><path d="M16 10C16 12.7614 13.7614 15 11 15C8.23858 15 6 12.7614 6 10C6 7.23858 8.23858 5 11 5C13.7614 5 16 7.23858 16 10Z" style="fill: #000;"/><path d="M16 10C16 12.7614 13.7614 15 11 15C8.23858 15 6 12.7614 6 10C6 7.23858 8.23858 5 11 5C13.7614 5 16 7.23858 16 10ZM16 10H27M27 10L23 6M27 10L23 14" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M32 38C32 40.7614 34.2386 43 37 43C39.7614 43 42 40.7614 42 38C42 35.2386 39.7614 33 37 33C34.2386 33 32 35.2386 32 38Z" style="fill: #000;"/><path d="M32 38C32 40.7614 34.2386 43 37 43C39.7614 43 42 40.7614 42 38C42 35.2386 39.7614 33 37 33C34.2386 33 32 35.2386 32 38ZM32 38H21M21 38L25 34M21 38L25 42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 11C33 13.7614 35.2386 16 38 16C40.7614 16 43 13.7614 43 11C43 8.23858 40.7614 6 38 6C35.2386 6 33 8.23858 33 11Z" style="fill: #000;"/><path d="M38 16C35.2386 16 33 13.7614 33 11C33 8.23858 35.2386 6 38 6C40.7614 6 43 8.23858 43 11C43 13.7614 40.7614 16 38 16ZM38 16V27M38 27L42 23M38 27L34 23" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 37C5 34.2386 7.23858 32 10 32C12.7614 32 15 34.2386 15 37C15 39.7614 12.7614 42 10 42C7.23858 42 5 39.7614 5 37Z" style="fill: #000;"/><path d="M10 32C7.23858 32 5 34.2386 5 37C5 39.7614 7.23858 42 10 42C12.7614 42 15 39.7614 15 37C15 34.2386 12.7614 32 10 32ZM10 32V21M10 21L14 25M10 21L6 25" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g></g><g class="geetest_frame_hash geetest_frame_3_hash geetest_frame_active_hash"><rect class="geetest_grid_hash" x="0" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,62.5) scale(0.8) translate(-24,-24)"><rect x="10" y="6" width="28" height="36" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M20.643 23.8886C22.0743 22.0081 23.1776 19.4103 23.774 18C24.8177 19.4103 27.084 22.9484 27.7997 24.8288C28.6942 27.1793 26.4578 30 23.774 30C21.0903 30 18.8538 26.2391 20.643 23.8886Z" style="fill: #000;" stroke="#FFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 6H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 42H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 24H10" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M38 24H42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="0" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,62.5) scale(0.8) translate(-24,-24)"><path d="M30.2972 18.7786C30.2972 18.7786 27.0679 27.8809 25.5334 29.47C23.9988 31.0591 21.4665 31.1033 19.8774 29.5687C18.2882 28.0341 18.244 25.5019 19.7786 23.9127C21.3132 22.3236 30.2972 18.7786 30.2972 18.7786Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M38.8492 38.8492C42.6495 35.049 45 29.799 45 24C45 12.402 35.598 3 24 3C12.402 3 3 12.402 3 24C3 29.799 5.35051 35.049 9.15076 38.8492" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 4V8" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M38.8454 11.1421L35.7368 13.6593" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M42.5223 27.2328L38.6248 26.333" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M5.47737 27.2328L9.37485 26.333" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.15463 11.142L12.2632 13.6593" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="0" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(72.5,197.5) scale(0.8) translate(-24,-24)"><path d="M16 10C16 12.7614 13.7614 15 11 15C8.23858 15 6 12.7614 6 10C6 7.23858 8.23858 5 11 5C13.7614 5 16 7.23858 16 10Z" style="fill: #000;"/><path d="M16 10C16 12.7614 13.7614 15 11 15C8.23858 15 6 12.7614 6 10C6 7.23858 8.23858 5 11 5C13.7614 5 16 7.23858 16 10ZM16 10H27M27 10L23 6M27 10L23 14" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M32 38C32 40.7614 34.2386 43 37 43C39.7614 43 42 40.7614 42 38C42 35.2386 39.7614 33 37 33C34.2386 33 32 35.2386 32 38Z" style="fill: #000;"/><path d="M32 38C32 40.7614 34.2386 43 37 43C39.7614 43 42 40.7614 42 38C42 35.2386 39.7614 33 37 33C34.2386 33 32 35.2386 32 38ZM32 38H21M21 38L25 34M21 38L25 42" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 11C33 13.7614 35.2386 16 38 16C40.7614 16 43 13.7614 43 11C43 8.23858 40.7614 6 38 6C35.2386 6 33 8.23858 33 11Z" style="fill: #000;"/><path d="M38 16C35.2386 16 33 13.7614 33 11C33 8.23858 35.2386 6 38 6C40.7614 6 43 8.23858 43 11C43 13.7614 40.7614 16 38 16ZM38 16V27M38 27L42 23M38 27L34 23" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 37C5 34.2386 7.23858 32 10 32C12.7614 32 15 34.2386 15 37C15 39.7614 12.7614 42 10 42C7.23858 42 5 39.7614 5 37Z" style="fill: #000;"/><path d="M10 32C7.23858 32 5 34.2386 5 37C5 39.7614 7.23858 42 10 42C12.7614 42 15 39.7614 15 37C15 34.2386 12.7614 32 10 32ZM10 32V21M10 21L14 25M10 21L6 25" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g><rect class="geetest_grid_hash" x="155" y="135" width="145" height="125" rx="8" style="fill: #e8eaed;" /><g transform="translate(227.5,197.5) scale(0.8) translate(-24,-24)"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 12C10.2091 12 12 10.2091 12 8C12 5.79086 10.2091 4 8 4C5.79086 4 4 5.79086 4 8C4 10.2091 5.79086 12 8 12Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path fill-rule="evenodd" clip-rule="evenodd" d="M10 42C13.3137 42 16 39.3137 16 36C16 32.6863 13.3137 30 10 30C6.68629 30 4 32.6863 4 36C4 39.3137 6.68629 42 10 42Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path fill-rule="evenodd" clip-rule="evenodd" d="M38 44C41.3137 44 44 41.3137 44 38C44 34.6863 41.3137 32 38 32C34.6863 32 32 34.6863 32 38C32 41.3137 34.6863 44 38 44Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path fill-rule="evenodd" clip-rule="evenodd" d="M22 28C26.4183 28 30 24.4183 30 20C30 15.5817 26.4183 12 22 12C17.5817 12 14 15.5817 14 20C14 24.4183 17.5817 28 22 28Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path fill-rule="evenodd" clip-rule="evenodd" d="M34 12C36.2091 12 38 10.2091 38 8C38 5.79086 36.2091 4 34 4C31.7909 4 30 5.79086 30 8C30 10.2091 31.7909 12 34 12Z" style="fill: #000;" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 11L15 15" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M30 12L28 14" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M34 33.5L28 26" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M14 31L18 27" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>


回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值
结帖率:100% (20/20)

签到天数: 24 天

发表于 2025-9-22 13:41:04 | 显示全部楼层   湖南省长沙市
回复

使用道具 举报

结帖率:0% (0/1)
 楼主| 发表于 2025-9-22 13:59:44 | 显示全部楼层   广东省广州市
曦月 发表于 2025-9-22 13:41
svg转png
https://bbs.ijingyi.com/forum.php?mod=viewthread&tid=14844082

转出来的图片和原图不一样
回复

使用道具 举报

结帖率:98% (57/58)
发表于 2025-9-22 14:10:19 | 显示全部楼层   广西壮族自治区南宁市
[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SVG转PNG - 在线转换工具</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link  rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3B82F6',
                        secondary: '#10B981',
                        neutral: '#1F2937',
                        light: '#F9FAFB',
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .shadow-soft {
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            }
            .transition-all-300 {
                transition: all 300ms ease-in-out;
            }
        }
    </style>
</head>
<body class="font-inter bg-gray-50 min-h-screen flex flex-col">
    <!-- 顶部导航 -->
    <header class="bg-white shadow-sm sticky top-0 z-50 transition-all duration-300">
        <div class="container mx-auto px-4 py-4 flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fa fa-exchange text-primary text-2xl"></i>
                <h1 class="text-xl md:text-2xl font-bold text-neutral">SVG 转 PNG</h1>
            </div>
            <div class="hidden md:flex items-center space-x-6">
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">首页</a>
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">使用指南</a>
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">关于我们</a>
            </div>
            <button class="md:hidden text-gray-600 focus:outline-none">
                <i class="fa fa-bars text-xl"></i>
            </button>
        </div>
    </header>

    <!-- 主要内容 -->
    <main class="flex-grow container mx-auto px-4 py-8 md:py-16">
        <!-- 介绍部分 -->
        <section class="text-center mb-12">
            <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-neutral mb-4">简单高效的 SVG 转 PNG 工具</h2>
            <p class="text-gray-600 max-w-2xl mx-auto text-lg">上传您的 SVG 文件,一键转换为高质量 PNG 图像,支持自定义尺寸和下载设置。</p>
        </section>

        <!-- 转换区域 -->
        <section class="max-w-5xl mx-auto">
            <div class="bg-white rounded-xl shadow-soft p-6 md:p-8 mb-8">
                <!-- 上传区域 -->
                <div id="upload-area" class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center hover:border-primary transition-all-300 cursor-pointer">
                    <input type="file" id="svg-file" accept="image/svg+xml" class="hidden">
                    <div class="space-y-4">
                        <i class="fa fa-cloud-upload text-5xl text-gray-400"></i>
                        <h3 class="text-xl font-medium text-neutral">拖放 SVG 文件到此处,或点击上传</h3>
                        <p class="text-gray-500">支持标准 SVG 格式文件</p>
                        <button id="browse-btn" class="bg-primary hover:bg-primary/90 text-white py-2 px-6 rounded-lg transition-all-300 font-medium">
                            <i class="fa fa-folder-open mr-2"></i>浏览文件
                        </button>
                    </div>
                </div>

                <!-- 预览和设置区域 (默认隐藏) -->
                <div id="preview-section" class="mt-8 hidden">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                        <!-- SVG 预览 -->
                        <div>
                            <h3 class="text-lg font-medium text-neutral mb-4">SVG 预览</h3>
                            <div id="svg-preview-container" class="border border-gray-200 rounded-lg p-4 bg-gray-50 min-h-[200px] flex items-center justify-center">
                                <div id="svg-preview" class="max-w-full max-h-[300px]"></div>
                            </div>
                        </div>

                        <!-- 转换设置 -->
                        <div>
                            <h3 class="text-lg font-medium text-neutral mb-4">转换设置</h3>
                            <div class="space-y-4">
                                <div>
                                    <label class="block text-gray-700 mb-1">宽度 (像素)</label>
                                    <input type="number" id="png-width" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary" value="800">
                                </div>
                                <div>
                                    <label class="block text-gray-700 mb-1">高度 (像素)</label>
                                    <input type="number" id="png-height" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary" value="600">
                                </div>
                                <div>
                                    <label class="block text-gray-700 mb-1">背景颜色</label>
                                    <div class="flex space-x-2">
                                        <input type="color" id="bg-color" class="w-10 h-10 p-0 border border-gray-300 rounded" value="#ffffff">
                                        <input type="text" id="bg-color-text" class="flex-grow px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary" value="#FFFFFF">
                                    </div>
                                </div>
                                <div>
                                    <label class="flex items-center">
                                        <input type="checkbox" id="preserve-aspect" class="mr-2" checked>
                                        <span class="text-gray-700">保持纵横比</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 转换和下载按钮 -->
                    <div class="mt-8 flex justify-center">
                        <button id="convert-btn" class="bg-secondary hover:bg-secondary/90 text-white py-3 px-8 rounded-lg transition-all-300 font-medium text-lg mr-4 flex items-center">
                            <i class="fa fa-magic mr-2"></i>转换为 PNG
                        </button>
                        <button id="download-btn" class="bg-primary hover:bg-primary/90 text-white py-3 px-8 rounded-lg transition-all-300 font-medium text-lg hidden flex items-center">
                            <i class="fa fa-download mr-2"></i>下载 PNG
                        </button>
                    </div>

                    <!-- PNG 预览 (默认隐藏) -->
                    <div id="png-preview-section" class="mt-8 hidden">
                        <h3 class="text-lg font-medium text-neutral mb-4">PNG 预览</h3>
                        <div class="border border-gray-200 rounded-lg p-4 bg-gray-50 min-h-[200px] flex items-center justify-center">
                            <img id="png-preview" class="max-w-full max-h-[300px]" alt="PNG 预览图">
                        </div>
                    </div>
                </div>
            </div>

            <!-- 转换历史 (默认隐藏) -->
            <div id="history-section" class="bg-white rounded-xl shadow-soft p-6 md:p-8 hidden">
                <h3 class="text-xl font-medium text-neutral mb-4 flex items-center">
                    <i class="fa fa-history mr-2 text-primary"></i>转换历史
                </h3>
                <div id="conversion-history" class="space-y-3">
                    <!-- 历史记录将在这里动态添加 -->
                </div>
            </div>
        </section>

        <!-- 功能特点 -->
        <section class="mt-16">
            <h2 class="text-2xl font-bold text-center text-neutral mb-10">为什么选择我们的转换工具</h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 max-w-5xl mx-auto">
                <div class="bg-white p-6 rounded-xl shadow-soft hover:shadow-lg transition-all-300">
                    <div class="w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center mb-4">
                        <i class="fa fa-bolt text-primary text-xl"></i>
                    </div>
                    <h3 class="text-lg font-medium text-neutral mb-2">快速转换</h3>
                    <p class="text-gray-600">本地处理您的文件,无需上传到服务器,转换速度快且保护隐私</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-soft hover:shadow-lg transition-all-300">
                    <div class="w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center mb-4">
                        <i class="fa fa-sliders text-primary text-xl"></i>
                    </div>
                    <h3 class="text-lg font-medium text-neutral mb-2">自定义设置</h3>
                    <p class="text-gray-600">支持调整输出尺寸、背景颜色等参数,满足您的个性化需求</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-soft hover:shadow-lg transition-all-300">
                    <div class="w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center mb-4">
                        <i class="fa fa-shield text-primary text-xl"></i>
                    </div>
                    <h3 class="text-lg font-medium text-neutral mb-2">安全可靠</h3>
                    <p class="text-gray-600">所有转换都在您的浏览器中完成,不会上传您的文件,保障数据安全</p>
                </div>
            </div>
        </section>

        <!-- 使用统计 -->
        <section class="mt-16 bg-white rounded-xl shadow-soft p-6 md:p-8 max-w-5xl mx-auto">
            <h2 class="text-2xl font-bold text-neutral mb-6">使用统计</h2>
            <div class="h-[300px]">
                <canvas id="stats-chart"></canvas>
            </div>
        </section>
    </main>

    <!-- 页脚 -->
    <footer class="bg-neutral text-white py-12">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <div class="flex items-center space-x-2 mb-4">
                        <i class="fa fa-exchange text-primary text-2xl"></i>
                        <h3 class="text-xl font-bold">SVG 转 PNG</h3>
                    </div>
                    <p class="text-gray-400">一款简单高效的在线 SVG 转 PNG 转换工具,帮助您轻松处理图像格式转换需求。</p>
                </div>
                <div>
                    <h4 class="text-lg font-medium mb-4">快速链接</h4>
                    <ul class="space-y-2 text-gray-400">
                        <li><a href="#" class="hover:text-primary transition-colors">首页</a></li>
                        <li><a href="#" class="hover:text-primary transition-colors">使用指南</a></li>
                        <li><a href="#" class="hover:text-primary transition-colors">常见问题</a></li>
                        <li><a href="#" class="hover:text-primary transition-colors">联系我们</a></li>
                    </ul>
                </div>
                <div>
                    <h4 class="text-lg font-medium mb-4">关注我们</h4>
                    <div class="flex space-x-4">
                        <a href="#" class="w-10 h-10 rounded-full bg-gray-700 flex items-center justify-center hover:bg-primary transition-colors">
                            <i class="fa fa-twitter"></i>
                        </a>
                        <a href="#" class="w-10 h-10 rounded-full bg-gray-700 flex items-center justify-center hover:bg-primary transition-colors">
                            <i class="fa fa-github"></i>
                        </a>
                        <a href="#" class="w-10 h-10 rounded-full bg-gray-700 flex items-center justify-center hover:bg-primary transition-colors">
                            <i class="fa fa-linkedin"></i>
                        </a>
                    </div>
                    <p class="mt-4 text-gray-400">订阅我们的更新</p>
                    <div class="mt-2 flex">
                        <input type="email" placeholder="您的邮箱地址" class="px-3 py-2 rounded-l-lg focus:outline-none text-gray-800 flex-grow">
                        <button class="bg-primary hover:bg-primary/90 px-4 py-2 rounded-r-lg transition-colors">
                            <i class="fa fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-700 text-center text-gray-500">
                <p>© 2023 SVG 转 PNG 工具 - 保留所有权利</p>
            </div>
        </div>
    </footer>

    <!-- 通知提示 -->
    <div id="notification" class="fixed bottom-4 right-4 bg-neutral text-white px-6 py-3 rounded-lg shadow-lg transform translate-y-20 opacity-0 transition-all-300 flex items-center">
        <i id="notification-icon" class="fa fa-check-circle mr-2"></i>
        <span id="notification-message"></span>
    </div>

    <script>
        // DOM 元素
        const uploadArea = document.getElementById('upload-area');
        const svgFileInput = document.getElementById('svg-file');
        const browseBtn = document.getElementById('browse-btn');
        const previewSection = document.getElementById('preview-section');
        const svgPreview = document.getElementById('svg-preview');
        const pngWidthInput = document.getElementById('png-width');
        const pngHeightInput = document.getElementById('png-height');
        const bgColorInput = document.getElementById('bg-color');
        const bgColorTextInput = document.getElementById('bg-color-text');
        const preserveAspectCheckbox = document.getElementById('preserve-aspect');
        const convertBtn = document.getElementById('convert-btn');
        const downloadBtn = document.getElementById('download-btn');
        const pngPreviewSection = document.getElementById('png-preview-section');
        const pngPreview = document.getElementById('png-preview');
        const historySection = document.getElementById('history-section');
        const conversionHistory = document.getElementById('conversion-history');
        const notification = document.getElementById('notification');
        const notificationIcon = document.getElementById('notification-icon');
        const notificationMessage = document.getElementById('notification-message');

        // 全局变量
        let currentSvgData = null;
        let currentPngData = null;
        let svgOriginalWidth = 0;
        let svgOriginalHeight = 0;

        // 初始化统计图表
        function initStatsChart() {
            const ctx = document.getElementById('stats-chart').getContext('2d');
            new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                    datasets: [{
                        label: '转换次数',
                        data: [120, 190, 300, 500, 450, 600, 550],
                        backgroundColor: 'rgba(59, 130, 246, 0.7)',
                        borderColor: 'rgba(59, 130, 246, 1)',
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        y: {
                            beginAtZero: true
                        }
                    }
                }
            });
        }

        // 显示通知
        function showNotification(message, isSuccess = true) {
            notificationMessage.textContent = message;
            notificationIcon.className = isSuccess ? 'fa fa-check-circle mr-2' : 'fa fa-exclamation-circle mr-2 text-red-500';
            notification.classList.remove('translate-y-20', 'opacity-0');
            notification.classList.add('translate-y-0', 'opacity-100');
            
            setTimeout(() => {
                notification.classList.remove('translate-y-0', 'opacity-100');
                notification.classList.add('translate-y-20', 'opacity-0');
            }, 3000);
        }

        // 处理文件上传
        function handleFileUpload(file) {
            if (!file.type.match('image/svg+xml')) {
                showNotification('请上传SVG格式的文件', false);
                return;
            }

            const reader = new FileReader();
            reader.onload = function(e) {
                currentSvgData = e.target.result;
                displaySvgPreview(currentSvgData);
                previewSection.classList.remove('hidden');
                downloadBtn.classList.add('hidden');
                pngPreviewSection.classList.add('hidden');
                
                // 显示历史记录区域
                historySection.classList.remove('hidden');
                
                showNotification('SVG文件已加载');
            };
            reader.readAsDataURL(file);
        }

        // 显示SVG预览
        function displaySvgPreview(svgData) {
            svgPreview.innerHTML = '';
            
            const img = new Image();
            img.onload = function() {
                // 获取原始尺寸
                svgOriginalWidth = img.width;
                svgOriginalHeight = img.height;
                
                // 设置默认尺寸
                pngWidthInput.value = svgOriginalWidth;
                pngHeightInput.value = svgOriginalHeight;
                
                svgPreview.appendChild(img);
            };
            img.src = svgData;
        }

        // 转换SVG为PNG
        function convertSvgToPng() {
            const width = parseInt(pngWidthInput.value) || 800;
            const height = parseInt(pngHeightInput.value) || 600;
            const bgColor = bgColorInput.value;
            
            // 创建一个临时的SVG元素
            const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
            svg.setAttribute('width', width);
            svg.setAttribute('height', height);
            svg.style.backgroundColor = bgColor;
            
            // 解析SVG数据
            const parser = new DOMParser();
            const svgDoc = parser.parseFromString(atob(currentSvgData.split(',')[1]), "image/svg+xml");
            const svgElement = svgDoc.querySelector('svg');
            
            // 如果SVG有viewBox,我们使用它来保持比例
            if (svgElement.hasAttribute('viewBox')) {
                const viewBox = svgElement.getAttribute('viewBox').split(' ').map(Number);
                const svgWidth = viewBox[2] - viewBox[0];
                const svgHeight = viewBox[3] - viewBox[1];
                
                // 创建一个group元素来应用变换
                const g = document.createElementNS("http://www.w3.org/2000/svg", "g");
                
                // 计算缩放比例
                let scaleX = width / svgWidth;
                let scaleY = height / svgHeight;
                let scale = Math.min(scaleX, scaleY);
                
                // 如果不保持比例,则使用单独的缩放
                if (!preserveAspectCheckbox.checked) {
                    scale = 1;
                    scaleX = width / svgWidth;
                    scaleY = height / svgHeight;
                } else {
                    scaleX = scale;
                    scaleY = scale;
                }
                
                // 应用缩放和平移使图像居中
                const translateX = (width - svgWidth * scaleX) / 2;
                const translateY = (height - svgHeight * scaleY) / 2;
                
                g.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${scaleX}, ${scaleY})`);
                
                // 将原始SVG的内容添加到group中
                while (svgElement.firstChild) {
                    g.appendChild(svgElement.firstChild);
                }
                
                svg.appendChild(g);
            } else {
                // 如果没有viewBox,直接使用原始尺寸
                svgElement.setAttribute('width', width);
                svgElement.setAttribute('height', height);
                svg.appendChild(svgElement);
            }
            
            // 创建canvas元素
            const canvas = document.createElement('canvas');
            canvas.width = width;
            canvas.height = height;
            const ctx = canvas.getContext('2d');
            
            // 将SVG转换为数据URL
            const svgDataUrl = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(new XMLSerializer().serializeToString(svg));
            
            // 绘制到canvas
            const img = new Image();
            img.onload = function() {
                ctx.fillStyle = bgColor;
                ctx.fillRect(0, 0, width, height);
                ctx.drawImage(img, 0, 0);
                
                // 获取PNG数据URL
                currentPngData = canvas.toDataURL('image/png');
                
                // 显示PNG预览
                pngPreview.src = currentPngData;
                pngPreviewSection.classList.remove('hidden');
                
                // 显示下载按钮
                downloadBtn.classList.remove('hidden');
                
                // 添加到历史记录
                addToHistory(currentSvgData, currentPngData);
                
                showNotification('SVG已成功转换为PNG');
            };
            img.src = svgDataUrl;
        }

        // 下载PNG文件
        function downloadPng() {
            if (!currentPngData) return;
            
            const a = document.createElement('a');
            a.href = currentPngData;
            a.download = 'converted-image.png';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            
            showNotification('PNG文件已下载');
        }

        // 添加到转换历史
        function addToHistory(svgData, pngData) {
            const date = new Date();
            const timeString = date.toLocaleTimeString();
            
            const historyItem = document.createElement('div');
            historyItem.className = 'p-3 border border-gray-200 rounded-lg flex justify-between items-center hover:bg-gray-50 transition-all-300';
            
            historyItem.innerHTML = `
                <div>
                    <p class="text-gray-700">转换于 ${timeString}</p>
                    <p class="text-gray-500 text-sm">${pngWidthInput.value} × ${pngHeightInput.value} 像素</p>
                </div>
                <button class="text-primary hover:text-primary/80 transition-colors" data-png="${pngData}">
                    <i class="fa fa-download"></i>
                </button>
            `;
            
            // 添加下载事件
            historyItem.querySelector('button').addEventListener('click', function() {
                const a = document.createElement('a');
                a.href = this.getAttribute('data-png');
                a.download = `image-${Date.now()}.png`;
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
                
                showNotification('历史文件已下载');
            });
            
            // 添加到历史记录顶部
            if (conversionHistory.firstChild) {
                conversionHistory.insertBefore(historyItem, conversionHistory.firstChild);
            } else {
                conversionHistory.appendChild(historyItem);
            }
        }

        // 事件监听
        uploadArea.addEventListener('click', () => svgFileInput.click());
        browseBtn.addEventListener('click', () => svgFileInput.click());
        
        uploadArea.addEventListener('dragover', (e) => {
            e.preventDefault();
            uploadArea.classList.add('border-primary', 'bg-primary/5');
        });
        
        uploadArea.addEventListener('dragleave', () => {
            uploadArea.classList.remove('border-primary', 'bg-primary/5');
        });
        
        uploadArea.addEventListener('drop', (e) => {
            e.preventDefault();
            uploadArea.classList.remove('border-primary', 'bg-primary/5');
            
            if (e.dataTransfer.files.length) {
                handleFileUpload(e.dataTransfer.files[0]);
            }
        });
        
        svgFileInput.addEventListener('change', (e) => {
            if (e.target.files.length) {
                handleFileUpload(e.target.files[0]);
            }
        });
        
        // 背景颜色同步
        bgColorInput.addEventListener('input', () => {
            bgColorTextInput.value = bgColorInput.value.toUpperCase();
        });
        
        bgColorTextInput.addEventListener('input', () => {
            if (/^#[0-9A-F]{6}$/i.test(bgColorTextInput.value)) {
                bgColorInput.value = bgColorTextInput.value;
            }
        });
        
        // 尺寸调整时保持比例
        pngWidthInput.addEventListener('input', () => {
            if (preserveAspectCheckbox.checked && svgOriginalWidth && svgOriginalHeight) {
                const ratio = svgOriginalHeight / svgOriginalWidth;
                pngHeightInput.value = Math.round(parseInt(pngWidthInput.value) * ratio);
            }
        });
        
        pngHeightInput.addEventListener('input', () => {
            if (preserveAspectCheckbox.checked && svgOriginalWidth && svgOriginalHeight) {
                const ratio = svgOriginalWidth / svgOriginalHeight;
                pngWidthInput.value = Math.round(parseInt(pngHeightInput.value) * ratio);
            }
        });
        
        convertBtn.addEventListener('click', convertSvgToPng);
        downloadBtn.addEventListener('click', downloadPng);

        // 初始化图表
        initStatsChart();
    </script>
</body>
</html>

回复

使用道具 举报

结帖率:99% (109/110)
发表于 2025-9-22 14:14:14 | 显示全部楼层   浙江省温州市
搜 ji验验证

点评

  浙江省温州市  发表于 2025-9-22 14:14
回复

使用道具 举报

结帖率:55% (17/31)

签到天数: 16 天

发表于 2025-9-22 14:27:11 | 显示全部楼层   河北省邢台市
这个svg有css动画!市面上大部分svg转png都是静态的!肯定都不支持的!
回复

使用道具 举报

签到天数: 4 天

发表于 昨天 19:23 | 显示全部楼层   广西壮族自治区百色市
66666666666666666666666666666666666
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备2025452707号) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

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