文件格式任意转换助手Transfer Any File

离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser

PNG 转 Word——离线、字节原样进包、不上传PNG to Word offline — the bytes ride inside

两步:`png>html` 先把文件的**原始字节**读成 data URI 放进一张 `<img>`,`html>docx` 再把这份文档交给打包器。关键在第二步的形态——它**不是**把 HTML 逐段翻译成 Word 段落,而是把文档体作为一个 altChunk 塞进包里,所以 Word 打开时按那份 HTML 重新排版;而被搬动的图片更妙:打包器会把 `<img>` 上那条 `data:` **从标记里提出来,写成包里一个独立的 base64 媒体部件**,并把引用重写到那个部件(这条是被 e2e 用夹具专属载荷钉住的:图在包内可解析,渲染它不需要任何一次取数)。于是两件事同时成立——`.docx` 里没有 data URI 残留,而**像素与你的文件逐字节相同**(这条链全程不解码、不上画布,透明通道照旧)。第二件事关乎隐私:`html>docx` 在写出前跑一遍 `stripRemoteResources`,因为这份标记**由 Word 在你这台机器上渲染**,一条远程 `<img>` 会变成别的程序替发出的请求,既看不见也拦不住;内层那份文档 CSS 也随包走,它的版心今天实测约 800 px,所以图的显示宽度由它和 Word 的页面一起决定,而不是由本扩展决定。产出名 `converted.docx`,打包失败明确报 `errors.docxGen` 而不是交出一个半成品。这份 .docx 再交给本扩展的 Word→HTML 也能取回内层标记(那条路有 altChunk 恢复),往返不丢图。Two steps: `png>html` reads the file’s **raw bytes** into a data URI inside one `<img>`, and `html>docx` hands the document to the packer. The second step is the interesting one — it does not translate HTML into Word paragraphs; it carries the body in as an altChunk, so Word re-lays-it-out when the file opens. And the picture gets lifted further: the packer takes that `data:` off the `<img>` and writes it as its own base64 media part inside the package, rewriting the reference to point at the part (an end-to-end test pins this with a fixture-unique payload: the image resolves from inside the package, and drawing it costs no fetch). Two things follow — no data URI is left in the `.docx`, and the **pixels are byte-identical to your file**, since nothing on this chain decodes, resamples or recompresses, alpha included. The other consequence is privacy: `html>docx` strips remote references on the way out precisely because Word — not this extension — renders that markup on your machine, where one remote `<img>` would become a request issued by another application, invisible to every guard here. The inner document CSS goes in too, and its measure was measured today at about 800 px, so the picture’s displayed width is decided by that CSS and by Word’s page, not by this extension. The output is `converted.docx`; a packing failure reports `errors.docxGen` rather than handing back a half-written file. Feeding that `.docx` back through Word to HTML recovers the inner markup (that route has altChunk recovery), so the round trip keeps the picture.

一批转换结果卡片,含文件名、体积与下载入口
一次混合批量,一个 ZIP 下载One mixed batch, one ZIP download

这条链路怎么走How the route runs

PNGPNG HTMLHTML Word (.docx)Word (.docx)

共 2 步,由扩展的路径搜索自动选出,中间产物不落盘。2 steps, chosen by the extension's own path search; intermediate results never touch the disk.

会保留什么What carries over

  • 像素与透明通道逐字节不变:这条链不解码、不上画布、不再压一次Byte-identical pixels and alpha: no decode, no canvas, no second compression on this chain
  • 图片是包里的媒体部件,不是 data URI:Word 从包内解析,渲染它不需要联网The picture is a media part in the package, not a data URI: the reference reads from inside the file, so drawing it takes no request
  • 远程引用在写出前剥掉——那份标记由 Word 在你机器上渲染,不能替它决定要不要发请求Remote references are stripped before writing, because Word renders that markup on your machine — a request is not this extension’s call to make
  • 产物仍是 .docx 容器,内层标记能被本扩展的 Word→HTML 取回;其它程序怎么读这份 altChunk,由那一侧决定Still a .docx container whose inner markup this extension’s Word to HTML route can recover; how other programs read that altChunk is up to them
  • 一批最多 200 个文件、单个 100 MB,与其他路线共用同一道闸门Up to 200 files per batch and 100 MB each — the same gate every other route shares

如实说明的限制What it does not do

  • 文档体是 altChunk(内嵌的那份 HTML),不是 Word 原生段落:逐字排版与分页由 Word 打开时决定The body is an altChunk — that inner HTML — not native Word paragraphs, so Word decides typesetting and paging when it opens
  • 不产生可编辑的文字层:图就是图,Word 里选不中它里面的字,也没有题注、图文式样式可用No editable text layer: it stays a picture, its words cannot be selected, and there are no captions or picture styles to apply
  • 显示尺寸由内层 CSS 与 Word 页面共同决定,本扩展不给缩放参数;要精确控制尺寸请在 Word 里改Displayed size follows the inner CSS and Word’s page; this route exposes no scaling option — resize it in Word
  • 想要「一页一图」的 PDF 而不是文档,请走 PNG→PDF;想要能再编辑版式,图进 Word 也仍然只是图For one image per page take PNG to PDF; for a layout you can keep editing, a picture inside Word is still just a picture
  • 类型没被认出时(例如从 ZIP 解包的文件)前缀不是图片类型,Word 那一步会在写出前把 `src` 剥掉,那一格留空When the browser never identified the type — a file unpacked from a ZIP, say — the prefix is not an image type, so the Word step strips `src` before writing and leaves an empty slot
  • 动图 PNG 的帧不在我们处理的范围:这条路径只搬字节、不重编码,所以帧仍在包里;但帧检查只对 GIF 生效(`utils/core/animated-image.ts:16` 自陈范围),因此这里也不会出现任何丢帧提示The frames of an animated PNG are outside what this route touches: it carries the bytes without re-encoding, so they stay inside the package, and since the frame check covers GIF only (`utils/core/animated-image.ts:16` states its scope) no lost-frame notice appears here either
  • 打包失败会报 `errors.docxGen` 并点名该文件,不会交出一个半成品A packing failure reports `errors.docxGen` for that file rather than shipping a half-written file

实操提示Working with it

  • 只想放进网页:PNG→HTML 是这条的第一步,产物是 HTML 而不是 .docxTo put it in a web page: PNG to HTML is this route’s first step, and the artifact is HTML, not a .docx
  • 要每页一张图的文档:PNG→PDF,一图一页、最多 200 页For one image per page: PNG to PDF, a page per picture with a 200-page ceiling
  • 要文字版的内容:这需要 OCR,本扩展离线且不带模型,请自行用识别工具For the words inside the picture: that needs OCR, which this offline extension does not ship

常见问题Questions people actually ask

这样生成的 .docx,图片会不会变成「链接到外部文件」?Does the picture end up linked to an external file?

不会。打包器把那条 data URI 提成包里独立的媒体部件并重写引用,字节就在包里,换台机器、换个目录,引用读的都是包里那一份;这是被端到端测试用夹具专属载荷钉住的一条。No. The packer lifts that data URI out of the markup into its own media part and rewrites the reference, so the bytes live inside the package and another machine or folder still reads them from there — pinned by an end-to-end test using a fixture-unique payload.

如果 Word 打开它时提示在转换,是没生成好吗?What if Word says it is converting the file when it opens?

文档体是一段作为 altChunk 附在包里的 HTML,把它渲染成文档内容这一步发生在阅读器那一侧。如果它给了你一句转换提示,那正是它在做这件事,并不代表文件没生成好;本扩展无法预见它会说什么。排版同样由它决定——好处是带来它自己的分页与页面设置,代价是不存在「Word 原生段落」可供逐字改样式。The body is an HTML fragment attached to the package as an altChunk, and rendering it into document content happens on the reader’s side. If it shows a converting notice, that is it doing exactly this — not a sign the file came out wrong, and this extension cannot predict what it will say. Layout is likewise the reader’s: the upside is its own paging and page setup, the cost is that there are no native paragraphs to restyle word by word.

会被重编码或降分辨率吗?Will it be re-encoded or downscaled?

不会。这条链只做搬运:`png>html` 读原始字节,打包那一步把同一批字节写成媒体部件,中间没有 canvas、没有再压一次。要真的降尺寸或换格式,请走图片转图片那几页,那里才有尺寸与质量的开关。Neither. This chain only carries: `png>html` reads the raw bytes and the packer writes those same bytes as a media part — no canvas, no second compression. To actually shrink or reformat, take an image-to-image page, where the size and quality controls live.

不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.