Class: Ddr::Derivatives::PtifGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/ddr/derivatives/generators/ptif_generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#initialize

Constructor Details

This class inherits a constructor from Ddr::Derivatives::Generator

Class Method Details

.output_extensionObject



11
12
13
# File 'lib/ddr/derivatives/generators/ptif_generator.rb', line 11

def self.output_extension
  "ptif"
end

.output_mime_typeObject



7
8
9
# File 'lib/ddr/derivatives/generators/ptif_generator.rb', line 7

def self.output_mime_type
  "image/tiff"
end

Instance Method Details

#generate(source_path, output_path) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ddr/derivatives/generators/ptif_generator.rb', line 15

def generate(source_path, output_path)
  case source_depth(source_path).strip
  when '16'
    Dir.mktmpdir do |dir|
      temp_8_bit_path = make_8_bit(dir, source_path)
      run_generator(temp_8_bit_path, output_path)
    end
  when '8'
    run_generator(source_path, output_path)
  else
    raise Ddr::Models::DerivativeGenerationFailure,
            "Unexpected depth #{source_depth} for source file #{Ddr::Utils.file_path(source_path)}"
  end
end