Class: Miso::Processor::ImageMagick
Instance Attribute Summary
#input_file
Class Method Summary
collapse
Instance Method Summary
collapse
#height, #initialize, #width
Class Method Details
.available? ⇒ Boolean
12
13
14
|
# File 'lib/miso/processor/image_magick.rb', line 12
def self.available?
!find_executable('convert').nil?
end
|
Instance Method Details
#_convert ⇒ Object
45
|
# File 'lib/miso/processor/image_magick.rb', line 45
alias_method :_convert, :convert
|
#auto_orient ⇒ Object
25
26
27
|
# File 'lib/miso/processor/image_magick.rb', line 25
def auto_orient
operations << "-auto-orient"
end
|
#convert(source_path, output_path, options) ⇒ Object
46
47
48
49
|
# File 'lib/miso/processor/image_magick.rb', line 46
def convert(source_path, output_path, options)
ensure_output_directory(output_path)
_convert "'#{source_path}' #{options} '#{output_path}'"
end
|
#crop(width, height) ⇒ Object
16
17
18
19
|
# File 'lib/miso/processor/image_magick.rb', line 16
def crop(width, height)
dimensions = "#{width}x#{height}"
operations << "-resize #{dimensions}^ -gravity center -crop #{dimensions}+0+0!"
end
|
#dimensions ⇒ Object
29
30
31
32
33
|
# File 'lib/miso/processor/image_magick.rb', line 29
def dimensions
if info = identify(input_file) and match = /\s(\d+)x(\d+)\+/.match(info)
match.to_a[1..2].map { |d| d.to_i }
end
end
|
#fit(width, height) ⇒ Object
21
22
23
|
# File 'lib/miso/processor/image_magick.rb', line 21
def fit(width, height)
operations << "-resize #{width}x#{height}"
end
|
#write(output_file) ⇒ Object
35
36
37
38
39
|
# File 'lib/miso/processor/image_magick.rb', line 35
def write(output_file)
options = operations.join(' ')
operations.clear
convert(input_file, output_file, options)
end
|