Class: DerivativeRodeo::Generators::MonochromeGenerator
- Inherits:
-
BaseGenerator
- Object
- BaseGenerator
- DerivativeRodeo::Generators::MonochromeGenerator
- Defined in:
- lib/derivative_rodeo/generators/monochrome_generator.rb
Overview
Take images an ensures that we have a monochrome derivative of those images.
Instance Attribute Summary
Attributes inherited from BaseGenerator
#input_uris, #output_extension, #output_location_template, #preprocessed_location_template
Instance Method Summary collapse
- #build_step(input_location:, output_location:, input_tmp_file_path:) ⇒ StorageLocations::BaseLocation
-
#monochromify(monochrome_file, image) ⇒ StorageLocations::BaseLocation
Convert the above image to a file at the monochrome_path.
Methods inherited from BaseGenerator
#derive_preprocessed_template_from, #destination, #generated_files, #generated_uris, #initialize, #input_files, #run, #valid_instantiation?, #with_each_requisite_location_and_tmp_file_path
Constructor Details
This class inherits a constructor from DerivativeRodeo::Generators::BaseGenerator
Instance Method Details
#build_step(input_location:, output_location:, input_tmp_file_path:) ⇒ StorageLocations::BaseLocation
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/derivative_rodeo/generators/monochrome_generator.rb', line 16 def build_step(input_location:, output_location:, input_tmp_file_path:) image = DerivativeRodeo::Services::ImageService.new(input_tmp_file_path) if image.monochrome? # The input_location is already have a monochrome file, no need to run conversions. input_location else # We need to write monochromify and the image. monochromify(output_location, image) end end |
#monochromify(monochrome_file, image) ⇒ StorageLocations::BaseLocation
Convert the above image to a file at the monochrome_path
33 34 35 36 37 |
# File 'lib/derivative_rodeo/generators/monochrome_generator.rb', line 33 def monochromify(monochrome_file, image) monochrome_file.with_new_tmp_path do |monochrome_path| image.convert(destination: monochrome_path, monochrome: true) end end |