Class: Quadtone::Tools::Separate
- Inherits:
-
Quadtone::Tool
- Object
- Quadtone::Tool
- Quadtone::Tools::Separate
- Defined in:
- lib/quadtone/tools/separate.rb
Instance Attribute Summary collapse
-
#gradient ⇒ Object
Returns the value of attribute gradient.
-
#montage ⇒ Object
Returns the value of attribute montage.
-
#save_luts ⇒ Object
Returns the value of attribute save_luts.
Attributes inherited from Quadtone::Tool
Instance Method Summary collapse
Methods inherited from Quadtone::Tool
#load_profile, #parse_global_option, process_args, #process_environment
Instance Attribute Details
#gradient ⇒ Object
Returns the value of attribute gradient.
8 9 10 |
# File 'lib/quadtone/tools/separate.rb', line 8 def gradient @gradient end |
#montage ⇒ Object
Returns the value of attribute montage.
7 8 9 |
# File 'lib/quadtone/tools/separate.rb', line 7 def montage @montage end |
#save_luts ⇒ Object
Returns the value of attribute save_luts.
9 10 11 |
# File 'lib/quadtone/tools/separate.rb', line 9 def save_luts @save_luts end |
Instance Method Details
#parse_option(option, args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/quadtone/tools/separate.rb', line 11 def parse_option(option, args) case option when '--montage' @montage = true when '--gradient' @gradient = true when '--save-luts' @save_luts = true end end |
#run(image_file = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/quadtone/tools/separate.rb', line 22 def run(image_file=nil) if @gradient image_file = Path.new('gradient.tif') image = Magick::Image.new(200, 200, Magick::GradientFill.new(0, 0, 0, 200, 'white', 'black')) else raise ToolUsageError, "Must specify image file (or --gradient option)" unless image_file image_file = Path.new(image_file) image = Magick::Image.read(image_file.to_s).first end quad = QuadFile.new(@profile) separator = Separator.new(quad.curve_set) images = separator.separate(image) if @montage image_list = Magick::ImageList.new image_copy = image.copy image_copy['Label'] = 'original' image_list << image_copy image_list += images.values separated_image = image_list.montage do self.frame = '2x2' self.geometry = '300x300' end separated_image_file = image_file.with_extname(".#{@profile.name}.sep.tif") ;;warn "writing montaged separated file to #{separated_image_file}" separated_image.write(separated_image_file) { self.compression = Magick::ZipCompression } else images.each do |channel, separated_image| separated_image_file = image_file.with_extname(".#{@profile.name}.sep-#{channel}.tif") ;;warn "writing channel #{channel} of separated file to #{separated_image_file}" separated_image.write(separated_image_file.to_s) { self.compression = Magick::ZipCompression } end end if @save_luts separator.luts.each do |channel, lut_image| lut_file = image_file.with_extname(".#{@profile.name}.lut-#{channel}.tif") ;;warn "writing LUT image to #{lut_file}" lut_image.write(lut_file) { self.compression = Magick::ZipCompression } end end end |