class Ddr::Derivatives::PtifGenerator
Public Class Methods
output_extension()
click to toggle source
# File lib/ddr/derivatives/generators/ptif_generator.rb, line 11 def self.output_extension "ptif" end
output_mime_type()
click to toggle source
# File lib/ddr/derivatives/generators/ptif_generator.rb, line 7 def self.output_mime_type "image/tiff" end
Public Instance Methods
generate(source_path, output_path)
click to toggle source
# 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
Private Instance Methods
make_8_bit(tempdir, source_path)
click to toggle source
# File lib/ddr/derivatives/generators/ptif_generator.rb, line 38 def make_8_bit(tempdir, source_path) temp_8_bit_path = File.join(tempdir, "temp_8_bit.v") command = "vips im_msb #{source_path} #{temp_8_bit_path}" out, err, s = Open3.capture3(command) if s.success? return temp_8_bit_path else raise Ddr::Models::DerivativeGenerationFailure, "Error converting #{source_path} to 8-bit: #{err}" end end
run_generator(source_to_use, output_path)
click to toggle source
# File lib/ddr/derivatives/generators/ptif_generator.rb, line 32 def run_generator(source_to_use, output_path) command = "vips im_vips2tiff #{source_to_use} #{output_path}:#{options}" out, err, s = Open3.capture3(command) GeneratorResult.new(output_path, out, err, s) end
source_depth(source_path)
click to toggle source
# File lib/ddr/derivatives/generators/ptif_generator.rb, line 50 def source_depth(source_path) `identify -quiet -format '%[depth]' #{source_path}[0]` end