Module: Pdfrb::ImageLoader::JPEG
- Defined in:
- lib/pdfrb/image_loader/jpeg.rb
Overview
JPEG loader. Parses the SOI/SOFn marker stream to extract width, height, bits-per-component, and number of components. The raw JPEG bytes are stored verbatim with /Filter /DCTDecode — no re-encoding.
Class Method Summary collapse
Class Method Details
.call(document, bytes, **_opts) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pdfrb/image_loader/jpeg.rb', line 21 def call(document, bytes, **_opts) return nil unless bytes.is_a?(::String) && bytes.start_with?(SOI) info = parse_header(bytes) image = document.add( { Type: :XObject, Subtype: :Image, Width: info[:width], Height: info[:height], BitsPerComponent: info[:precision], ColorSpace: info[:color_space], Filter: :DCTDecode }, type: Pdfrb::Model::Type::XObjectImage ) image.stream = bytes.b image end |