Module: Kreuzberg::ImageOutputFormat
- Extended by:
- T::Helpers, T::Sig
- Included in:
- ImageOutputFormatHeif, ImageOutputFormatJpeg, ImageOutputFormatNative, ImageOutputFormatPng, ImageOutputFormatSvg, ImageOutputFormatWebp
- Defined in:
- lib/kreuzberg/native.rb
Overview
Target format for re-encoding extracted images.
Controls whether and how extracted images are normalised to a uniform container format before being returned in ‘ExtractionResult.images`. The default (`Native`) preserves the format produced by each extractor without any additional encode pass.
Callers that need uniform output — e.g. cloud pipelines that always store WebP thumbnails — set this once on ‘ImageExtractionConfig.output_format` rather than re-encoding downstream.
# Serde shape
Uses a tagged enum: ‘“native”`, `“png”`, `“jpeg”, “quality”: 90`, etc.
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kreuzberg/native.rb', line 36 def self.from_hash(hash) discriminator = hash[:type] || hash["type"] case discriminator when "native" then ImageOutputFormatNative.from_hash(hash) when "png" then ImageOutputFormatPng.from_hash(hash) when "jpeg" then ImageOutputFormatJpeg.from_hash(hash) when "webp" then ImageOutputFormatWebp.from_hash(hash) when "heif" then ImageOutputFormatHeif.from_hash(hash) when "svg" then ImageOutputFormatSvg.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |