Class: ImageGenie::Montage
- Inherits:
-
Command
- Object
- Command
- ImageGenie::Montage
- Defined in:
- lib/image_genie/montage.rb
Instance Attribute Summary collapse
-
#filenames ⇒ Object
Returns the value of attribute filenames.
-
#options ⇒ Object
Returns the value of attribute options.
-
#temp_image_file ⇒ Object
Returns the value of attribute temp_image_file.
-
#temp_image_list_file ⇒ Object
Returns the value of attribute temp_image_list_file.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(filenames, options = {}) ⇒ Montage
constructor
A new instance of Montage.
- #output ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(filenames, options = {}) ⇒ Montage
Returns a new instance of Montage.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/image_genie/montage.rb', line 18 def initialize(filenames,={}) logger.info("#{self.class.name} Attempting to make montage of #{filenames.count} files") self.filenames = filenames self.exception_class = MontageError raise(UnableToLocateBinaryError, 'montage') if path_for(:montage).blank? self. = # Montage hates when you attempt to give it files with a path in it, so we # need to change to the system specified temp directory to do our work. Dir.chdir(Dir::tmpdir) self.temp_image_file = Tempfile.new(['montage','.jpg']) self.temp_image_list_file = Tempfile.new(['montage_image_filenames','.txt']) # Create a temp file that will be all component files of this montage temp_image_list_file.puts filenames.join("\n") temp_image_list_file.rewind super(self) end |
Instance Attribute Details
#filenames ⇒ Object
Returns the value of attribute filenames.
4 5 6 |
# File 'lib/image_genie/montage.rb', line 4 def filenames @filenames end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/image_genie/montage.rb', line 4 def end |
#temp_image_file ⇒ Object
Returns the value of attribute temp_image_file.
4 5 6 |
# File 'lib/image_genie/montage.rb', line 4 def temp_image_file @temp_image_file end |
#temp_image_list_file ⇒ Object
Returns the value of attribute temp_image_list_file.
4 5 6 |
# File 'lib/image_genie/montage.rb', line 4 def temp_image_list_file @temp_image_list_file end |
Instance Method Details
#cleanup ⇒ Object
13 14 15 16 |
# File 'lib/image_genie/montage.rb', line 13 def cleanup logger.info("#{self.class.name} Cleaning up files") temp_image_list_file.close end |
#output ⇒ Object
6 7 8 9 10 11 |
# File 'lib/image_genie/montage.rb', line 6 def output while !stdout.eof? temp_image_file.puts stdout.readline end temp_image_file.rewind end |
#run ⇒ Object
35 36 37 38 39 |
# File 'lib/image_genie/montage.rb', line 35 def run command = make_command(path_for(:montage), "@\"#{File.basename(temp_image_list_file.path)}\"", , "jpeg:-") execute(command) return temp_image_file end |