Class: ImageGenie::Identify

Inherits:
Command
  • Object
show all
Defined in:
lib/image_genie/identify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, options = {}) ⇒ Identify

Returns a new instance of Identify.



7
8
9
10
11
12
13
# File 'lib/image_genie/identify.rb', line 7

def initialize(filename, options={})
  self.exception_class = IdentifyError
  raise(UnableToLocateBinaryError, 'identify') if path_for(:identify).blank?
  self.filename = filename
  raise Errno::ENOENT,"#{filename}" unless File.exists?(filename)
  super(self)
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



5
6
7
# File 'lib/image_genie/identify.rb', line 5

def filename
  @filename
end

Instance Method Details

#runObject



15
16
17
18
19
20
# File 'lib/image_genie/identify.rb', line 15

def run
  command = "#{path_for(:identify)} #{filename}"
  execute(command)
  fields = [:filename,:format,:dimensions,:geometry,:bit,:image_class,:colors,:filesize,:usertime,:identify_time]                    
  return Hash[fields.zip(output_buffer.split(' '))]
end