离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
SVG 转 PNG——先净化再栅格化,脚本不执行SVG to PNG — sanitised first, rasterised second
SVG 是图,也是可执行标记:一段 <script> 或一个 onerror 属性就藏在“图片”里面。所以这条链路的第一步不是画图,是把活性内容剥掉——先剥离脚本与事件属性,再交给栅格化;这也是为什么它敢接受一个来路不明的 SVG。渲染按矢量在指定尺寸下重新计算,因此不是「放大已渲染的位图」,边缘保持锐利。An SVG is a picture and executable markup at the same time: a <script> element or an onerror attribute is still “an image” as far as a file picker is concerned. So the first step on this route is not drawing — it is removing live content, stripping scripts and event-handler attributes before anything is rasterised. That is what lets it accept an SVG of unknown origin at all. The render then recomputes the vector at the size you set, so it is not an upscale of an already-flattened bitmap and the edges stay sharp.
这条链路怎么走How the route runs
SVGSVG PNGPNG
共 1 步,由扩展的路径搜索自动选出,中间产物不落盘。1 step, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 矢量按目标尺寸重新计算:曲线与文字边缘不会因为转换而发虚The vector is recomputed at the target size, so curves and glyph edges do not soften through the conversion
- viewBox 与宽高按同一套规则归一,DOCX 里内联 SVG 走的是同一个栅格化实现viewBox and width/height are normalised by one shared rule — the same code path paints an inline SVG inside a DOCX
- 输出可选 PNG(保留透明)、JPEG 或 WebPOutput can be PNG (transparency preserved), JPEG or WebP
- 解析失败、根节点不是 <svg> 都会给出该文件的错误提示,而不是产出一张空白图A file that fails to parse, or whose root is not <svg>, reports its own error instead of handing back a blank image
如实说明的限制What it does not do
- 外链的东西一律不去取:远程 <image>、远程字体与 CSS 都不会被下载(离线前提),所以带外链的 SVG 需要先自备素材Nothing external is fetched: remote <image> references, remote fonts and external CSS are not downloaded — that is the offline premise — so bring the assets first
- 动画 SVG 只出一帧——栅格化是单张图像,SMIL/CSS 动画的时间轴不进 PNGAn animated SVG yields one frame only; rasterising produces a still, and a SMIL or CSS timeline does not enter the PNG
- 不能反向输出 SVG:浏览器不提供 SVG 编码器,SVG 只能作为输入格式There is no way back out to SVG: browsers ship no SVG encoder, so SVG is input-only
- 文字依赖本机字体,字体缺失时按系统回退渲染,字形宽度可能与原稿不同Text depends on fonts installed on your machine; a missing face falls back to a system font and changes glyph widths against the original
实操提示Working with it
- 图标工作流常见用法:一批 SVG 一次转成多尺寸 PNG(先设最长边,再跑第二批)A common icon workflow: convert a set of SVGs, set the longest edge, then run a second batch at another size
- 一批最多 200 个文件;结果可一次打包成 ZIPUp to 200 files per batch, downloadable as one ZIP
常见问题Questions people actually ask
为什么说「先净化」?What does “sanitised first” actually mean here?
栅格化前会移除 <script> 与 on* 事件属性,渲染路径本身也不允许脚本执行。这是把 SVG 当不可信输入处理的必要步骤,而不是可选开关。Before anything is drawn, <script> elements and on* handler attributes are removed and the render path itself gives scripts no way to execute. That is a necessary step in treating an SVG as untrusted input, not an optional switch.
透明背景会保留吗?Is the transparent background kept?
选 PNG 或 WebP 时保留;选 JPEG 时会被展平到不透明底色,因为 JPEG 没有 alpha 通道。With PNG or WebP, yes. With JPEG it is flattened onto an opaque background, because JPEG has no alpha channel.
为什么我的 SVG 变成了一张空图?Why did my SVG come out blank?
多半是内容依赖外部取码(远程图片或字体)或宽高无法归一。本项目不会去下载任何东西:把素材内联进 SVG、或为它显式指定宽高,再转一次。Usually it is content that expected a fetch — a remote image or font — or dimensions that could not be normalised. Nothing is downloaded here: inline the assets into the SVG, or give it an explicit width and height, and convert it again.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub
要把它压到指定体积?Need it under a target size? The 图片压缩工具image compressor可以在浏览器里重编码 PNG / JPEG / WebP。 re-encodes PNG / JPEG / WebP in the browser.