module

MJ::Arcana::Xcf

PNG -> XCF, via a headless GIMP.

Why bother, when XCF is many times larger than webp: XCF stores image data in TILES. Two revisions of the same picture that differ in a small region share almost all of their tiles, so a content-addressed store keeps one copy of the shared data and only the changed tiles per revision. Measured on a 768x1024 panel with a 64x64 edit (0.52% of pixels), chunked with a FastCDC-style rolling hash:

xcf 97.7% of chunks shared, 32,906 new bytes per revision png 0.0%, 680,927 new bytes — a full rewrite webp 0.0%, 88,694 new bytes — a full rewrite

Two caveats that decide whether it is worth it:

  1. It needs CONTENT-DEFINED chunking. With fixed-size blocks XCF shared only 4.6%, because GIMP RLE-compresses each tile, so one changed tile shifts every byte after it and fixed offsets stop lining up. FastCDC is fine; a fixed-block store is not.
  2. XCF's first copy is ~13x a webp. Break-even against storing a fresh webp each time is around 19 revisions. This is a format for art that gets edited repeatedly, and a bad deal for art written once.

Class methods

available?

Converting costs about 1.4s of local CPU — GIMP start-up dominates, not the image.

Source
convert(png : Bytes) : Bytes
Source

Nested types