JPG 故障艺术工具
JPG Glitch,Georg Fischer (snorpey),2013 年

正在布展…
它是怎么做的
- 第 1 步把图片用 canvas.toDataURL 编码为 JPEG 并转成字节数组
- 第 2 步跳过文件头,在扫描数据区按“数量”“种子”参数改写若干字节
- 第 3 步“迭代”参数控制改写次数,“质量”影响初始编码
- 第 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.


