Class: Mapel::Engine::ImageMagick
Instance Attribute Summary
#command, #commands, #output, #status
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #success?
Constructor Details
This class inherits a constructor from Mapel::Engine
Class Method Details
.info(source) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/mapel.rb', line 36
def self.info(source)
im = new(source)
im.commands << 'identify'
im.commands << source
im.run.to_info_hash
end
|
.list(type = nil) ⇒ Object
50
51
52
53
54
|
# File 'lib/mapel.rb', line 50
def self.list(type = nil)
im = new
im.commands << 'convert -list'
im.run
end
|
.render(source = nil) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/mapel.rb', line 43
def self.render(source = nil)
im = new(source)
im.commands << 'convert'
im.commands << source unless source.nil?
im
end
|
Instance Method Details
#crop(*args) ⇒ Object
56
57
58
59
|
# File 'lib/mapel.rb', line 56
def crop(*args)
@commands << "-crop \"#{Geometry.new(*args).to_s(true)}\""
self
end
|
#gravity(type = :center) ⇒ Object
61
62
63
64
|
# File 'lib/mapel.rb', line 61
def gravity(type = :center)
@commands << "-gravity #{type}"
self
end
|
#repage ⇒ Object
66
67
68
69
|
# File 'lib/mapel.rb', line 66
def repage
@commands << "+repage"
self
end
|
#resize(*args) ⇒ Object
71
72
73
74
|
# File 'lib/mapel.rb', line 71
def resize(*args)
@commands << "-resize \"#{Geometry.new(*args)}\""
self
end
|
#resize!(*args) ⇒ Object
76
77
78
79
|
# File 'lib/mapel.rb', line 76
def resize!(*args)
width, height = Geometry.new(*args).dimensions
resize("#{width}x#{height}^").crop(width, height).repage
end
|
#run ⇒ Object
96
97
98
99
100
|
# File 'lib/mapel.rb', line 96
def run
@output = `#{to_preview}`
@status = ($? == 0)
self
end
|
#scale(*args) ⇒ Object
81
82
83
84
|
# File 'lib/mapel.rb', line 81
def scale(*args)
@commands << "-scale \"#{Geometry.new(*args)}\""
self
end
|
#to(path) ⇒ Object
86
87
88
89
|
# File 'lib/mapel.rb', line 86
def to(path)
@commands << path
self
end
|
#to_info_hash ⇒ Object
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/mapel.rb', line 106
def to_info_hash
meta = @output.split(' ')
{
:path => meta[0],
:format => meta[1],
:dimensions => meta[2].split('x').map {|d| d.to_i},
:depth => meta[4],
:size => meta[6]
}
end
|
#to_preview ⇒ Object
102
103
104
|
# File 'lib/mapel.rb', line 102
def to_preview
@commands.map { |cmd| cmd.respond_to?(:call) ? cmd.call : cmd }.join(' ')
end
|
#undo ⇒ Object
91
92
93
94
|
# File 'lib/mapel.rb', line 91
def undo
@commands.pop
self
end
|