跳到正文
网页珍奇柜Web Curio

JPG 故障艺术工具

JPG Glitch,Georg Fischer (snorpey),2013 年

正在布展…

原作直展:这是 Georg Fischer (snorpey) 的原始作品,按 MIT 许可证收录(版本 c8bec1b)。原作的发布版本原样展出;沙盒里没有浏览器数据库,所以「保存到浏览器」不会保留。拖动底部滑块改变损坏程度,也可以打开自己的图片。 许可证全文 · 收录说明

它是怎么做的

  1. 第 1 步把图片用 canvas.toDataURL 编码为 JPEG 并转成字节数组
  2. 第 2 步跳过文件头,在扫描数据区按“数量”“种子”参数改写若干字节
  3. 第 3 步“迭代”参数控制改写次数,“质量”影响初始编码
  4. 第 4 步把被破坏的字节重新解码成图片显示,解码失败则回退

复刻配方

一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。

Encode the source image to JPEG at a chosen quality with canvas.toDataURL, decode the base64 into a byte array, and find the end of the header (after the start-of-scan marker). With a seeded random generator, overwrite a number of bytes in the scan data with new values, never touching the header or end marker. Turn the bytes back into a data URI, load it into an Image and draw it; if decoding fails, retry with a different seed. Run this in a Web Worker so slider changes stay responsive.

档案

能不能拿来用

原作以 MIT 许可开源:可以阅读源码学习,按许可证条款使用;在自己的项目里引用时保留原作者署名。

性能开销

视觉强度

实现难度

尺度为策展判断(1 到 5),用于比较和推荐。

核实记录:Opened http://snorpey.github.io/jpg-glitch/ (200, title 'Image Glitch Tool'); repo snorpey/jpg-glitch exists, licence MIT via GitHub API.