Search code examples
pdfjpeg

Is the JFIF APP0 marker needed with /Filter /DCTDecode PDF stream?


I'm generating a PDF file with a /Filter /DCTDecode (i.e. baseline JPEG) stream. My input JPEG file contains a JFIF APP0 marker, but no Exif markers. Is the JFIF marker necessarily to be included in the PDF stream for it to be valid, or can I remove it?


Solution

  • The PDF specification version 1.7 refers to Technical Note #5116: Supporting the DCT Filters in PostScript Level 2, which explains that /Filter /DCTDecode ignores the JFIF marker (and several other markers) in the JPEG, and it respoects the Adobe-specific APPE marker, which has a /ColorTransform field, which can specify e.g. conversion from YCbCr (YUV) to RGB.

    If the Adobe-specific APPE marker is missing from the JPEG stream, then the /ColorTransform field of the PDF image object can specify the transformation to be used. The default value is 1 if the image has 3 components, 0 otherwise. A value of 0 means no transformation, a value of 1 means transforming YUV to RGB or transforming YUVK to CMYK.