Module: Imogen::Iiif::Quality

Defined in:
lib/imogen/iiif.rb

Constant Summary collapse

VALUES =
{native: nil, default: nil, color: nil, bitonal: :bitonal, grey: :grey, gray: :grey}

Class Method Summary collapse

Class Method Details

.convert(img, quality) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/imogen/iiif.rb', line 30

def self.convert(img, quality)
  q = get(quality)
  if q == :grey
    yield img.copy(interpretation: :b_w)
  elsif q == :bitonal
    yield img.copy(interpretation: :b_w) > 128
  else
    yield img
  end
end

.get(quality = :native) ⇒ Object

Raises:



25
26
27
28
29
# File 'lib/imogen/iiif.rb', line 25

def self.get(quality=:native)
  q = (quality || :native).to_sym
  raise BadRequest.new("bad quality #{quality}") unless VALUES.include? q
  return VALUES[q]
end