class

PDF::Images::JPEG

Inherits PDF::Images::Base < Reference < Object

JPEG image handler with DCT passthrough.

JPEG images are embedded directly in PDFs using DCTDecode filter. The raw JPEG data is passed through without re-encoding, which:

  • Preserves original quality
  • Avoids decompression/recompression artifacts
  • Keeps file size optimal

Usage

jpeg = PDF::Images::JPEG.load("photo.jpg")
jpeg.width      # => 800
jpeg.height     # => 600
jpeg.color_space # => /DeviceRGB

Constructors

load(path : String) : JPEG

Load JPEG from file path

Source
load(io : IO) : JPEG

Load JPEG from IO

Source
load(data : Bytes) : JPEG

Load JPEG from bytes

Source
new(data : Bytes, width : Int32, height : Int32, components : Int32)
Source

Instance methods

bits_per_component

Bits per color component (typically 8)

Source
color_space

PDF color space name (/DeviceRGB, /DeviceGray, /DeviceCMYK)

Source
components

Color components (1=grayscale, 3=RGB, 4=CMYK)

Source
data

Raw JPEG data

Source
has_alpha?

Whether this image has transparency (alpha channel)

Source
height
Source
soft_mask_stream

Returns the soft mask stream for transparency (if applicable)

Source
to_stream

Create the image stream with DCT passthrough

Source
width

Image dimensions

Source