Parent

Methods

Prawn::Images::JPG

A convenience class that wraps the logic for extracting the parts of a JPG image that we need to embed them in a PDF

Constants

JPEG_SOF_BLOCKS
JPEG_APP_BLOCKS

Attributes

width[R]
height[R]
bits[R]
channels[R]
scaled_width[RW]
scaled_height[RW]

Public Class Methods

new(data) click to toggle source

Process a new JPG image

:data

A binary string of JPEG data

    # File lib/prawn/images/jpg.rb, line 27
27:       def initialize(data)
28:         data = StringIO.new(data.dup)
29: 
30:         c_marker = "\xff" # Section marker.
31:         data.read(2)   # Skip the first two bytes of JPEG identifier.
32:         loop do
33:           marker, code, length = data.read(4).unpack('aan')
34:           raise "JPEG marker not found!" if marker != c_marker
35: 
36:           if JPEG_SOF_BLOCKS.include?(code)
37:             @bits, @height, @width, @channels = data.read(6).unpack("CnnC")
38:             break
39:           end
40: 
41:           buffer = data.read(length - 2)
42:         end
43:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.