class HexaPDF::ImageLoader::PNG

Parent

This class is used for loading images in the PNG format from files or IO streams.

It can handle all five types of PNG images: greyscale w/wo alpha, truecolor w/wo alpha and indexed-color. Furthermore, it recognizes the gAMA, cHRM, sRGB and tRNS chunks and handles them appropriately. However, Adam7 interlaced images are not supported!

Note that greyscale, truecolor and indexed-color images with alpha need to be decoded to get the alpha channel which takes time.

All PNG specification section references are in reference to www.w3.org/TR/PNG/.

See: PDF2.0 s7.4.4., s8.9

Constants

GREYSCALE

The color type for PNG greyscale images without alpha, see PNG s11.2.2

GREYSCALE_ALPHA

The color type for PNG greyscale images with alpha, see PNG s11.2.2

INDEXED

The color type for PNG indexed images with/without alpha, see PNG s11.2.2

MAGIC_FILE_MARKER

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

See: PNG s5.2

RENDERING_INTENT_MAP

Mapping from sRGB chunk rendering intent byte to PDF rendering intent name.

SRGB_CHRM

The primary chromaticities and white point used by the sRGB specification.

TRUECOLOR

The color type for PNG truecolor images without alpha, see PNG s11.2.2

TRUECOLOR_ALPHA

The color type for PNG truecolor images with alpha, see PNG s11.2.2

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 PNG format.

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

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