class HexaPDF::Type::Image

Parent

Represents an image XObject of a PDF document.

See: PDF2.0 s8.8

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
LengthIntegerfalsenil
FilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
DecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
FHexaPDF::Type::FileSpecification or Hash or Stringfalsenil
FFilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
FDecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
DLIntegerfalsenil
TypeSymbolfalse:XObject
SubtypeSymboltrue:Image
WidthIntegertruenil
HeightIntegertruenil
ColorSpaceSymbol or HexaPDF::PDFArray or Arrayfalsenil
BitsPerComponentIntegerfalsenil
IntentSymbol
One of: :AbsoluteColorimetric, :RelativeColorimetric, :Saturation, :Perceptual
falsenil
ImageMaskTrueClass or FalseClassfalsefalse
MaskHexaPDF::Stream or HexaPDF::PDFArray or Hash or Arrayfalsenil
DecodeHexaPDF::PDFArray or Arrayfalsenil
InterpolateTrueClass or FalseClassfalsefalse
AlternatesHexaPDF::PDFArray or Arrayfalsenil
SMaskHexaPDF::Stream or Hashfalsenil
SMaskInDataInteger
One of: 0, 1, 2
falsenil
NameSymbolfalsenil
StructParentIntegerfalsenil
IDHexaPDF::DictionaryFields::PDFByteString or Stringfalsenil
OPIHexaPDF::Dictionary or Hashfalsenil
MetadataHexaPDF::Stream or Hashfalsenil
OCHexaPDF::Dictionary or Hashfalsenil
AFHexaPDF::PDFArray or Arrayfalsenil
MeasureHexaPDF::Dictionary or Hashfalsenil
PtDataHexaPDF::Dictionary or Hashfalsenil

Constants

Info

The structure that is returned by the Image#info method.

Attributes

source_path[RW]

Returns the source path that was used when creating the image object.

This value is only set when the image object was created by using the image loading facility and not when the image is part of a loaded PDF file.

Public Instance Methods

height()

Returns the height of the image.

info()

Returns an Info structure with information about the image.

Available accessors:

type

The type of the image. Either :jpeg, :jp2, :jbig2, :ccitt or :png.

width

The width of the image.

height

The height of the image.

color_space

The color space the image uses. Either :rgb, :cmyk, :gray or :other.

indexed

Whether the image uses an indexed color space or not.

components

The number of color components of the color space, or -1 if the number couldn’t be determined.

bits_per_component

The number of bits per color component.

writable

Whether the image can be written by HexaPDF.

extension

The file extension that would be used when writing the file. Either jpg, jpx or png. Only meaningful when writable is true.

width()

Returns the width of the image.

write(basename)
write(io)

Saves this image XObject to the file with the given name and appends the correct extension (if the name already contains this extension, the name is used as is), or the given IO object.

Raises an error if the image format is not supported.

The output format and extension depends on the image type as returned by the info method:

:jpeg

Saved as a JPEG file with the extension ‘.jpg’

:jp2

Saved as a JPEG2000 file with the extension ‘.jpx’

:png

Saved as a PNG file with the extension ‘.png’