5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/image_genie/identify.rb', line 5
def self.run(filename, options={})
raise(UnableToLocateBinaryError, 'identify') if path_for(:identify).blank?
begin
raise Errno::ENOENT,"#{filename}" unless File.exists?(filename)
rescue Errno::ENOENT => e
logger.error("#{self.name} #{e.message}")
raise
end
command = "#{path_for(:identify)} #{filename}"
output = ''
execute(command) do |pid,stdin,stdout,stderr|
while !stdout.eof?
output += stdout.readline
end
ignored, status = Process::waitpid2 pid
handle_errors(stderr,status,IdentifyError)
end
fields = [:filename,:format,:dimensions,:geometry,:bit,:image_class,:colors,:filesize,:usertime,:identify_time]
return Hash[fields.zip(stdout.read.split(' '))]
end
|