mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 17:56:50 -06:00
A CMYK JPEG came out with JFIF's APP0 segment at its head and four components in the frame: APP0/JFIF APP14/Adobe APP2[ICC_PROFILE 1/4 … 4/4] SOF0: 4 components JFIF describes one- and three-component images, greyscale and YCbCr, so an APP0 segment in front of a four-component frame says two different things about the file's colours: a reader that trusts JFIF decodes nonsense, and one that checks refuses the file. Adobe's own CMYK JPEGs carry the APP14 marker the encoder already writes, and no JFIF. `jpeg-encoder` writes JFIF unconditionally, so the segment is replaced here. The resolution JFIF carried moves to an EXIF APP1 segment -- `XResolution`, `YResolution` and `ResolutionUnit` -- which is where `cmd::fileio::ppi` already looks when a file has no JFIF, so nothing is lost; with no resolution asked for the segment is simply dropped. RGB and greyscale files keep JFIF, which is what it is for. Found while looking at #3084, whose default RGB exports are valid here; this is the file that is not.