module HexaPDF::ImageLoader::JPEG

This module is used for loading images in the JPEG format from files or IO streams.

See: PDF1.7 s7.4.8, ITU T.81 Annex B



Adobe uses the marker 0xEE (APPE) for its purposes. We need to use it for determinig whether to invert the colors for CMYK/YCCK images or not (Adobe does this…).

The marker also let's us distinguish between YCCK and CMYK images. However, we don't actually need this information (and we don't need to set the /ColorTransform value) because if the image has this information it is automically used.


End-of-image marker


The magic marker that tells us if the file/IO contains an image in JPEG format.


The various start-of-frame markers that tell us which kind of JPEG it is. The marker segment itself contains all the needed information needed for creating the PDF image object.

See: ITU T.81 B1.1.3


Start-of-scan marker

Public Class Methods

handles?(filename) → true or false
handles?(io) → true or false

Returns true if the given file or IO stream can be handled, ie. if it contains an image in JPEG format.

load(document, filename) → image_obj
load(document, io) → image_obj

Creates a PDF image object from the JPEG file or IO stream.