Class: GraphicsMagick::Image
- Inherits:
-
Object
- Object
- GraphicsMagick::Image
- Includes:
- Utilities
- Defined in:
- lib/graphicsmagick/image.rb
Constant Summary
Constants included from Utilities
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(input) ⇒ Image
constructor
A new instance of Image.
-
#path ⇒ Object
Returns the path of the associated file.
-
#write(output, opts = {}) ⇒ Object
Writes the changes to the file specified in
output
. -
#write!(opts = {}) ⇒ Object
Writes the changes to the current file.
Methods included from Utilities
Methods included from Utilities::Composite
Methods included from Utilities::Convert
Methods included from Utilities::Identify
Constructor Details
#initialize(input) ⇒ Image
Returns a new instance of Image.
16 17 18 19 20 21 |
# File 'lib/graphicsmagick/image.rb', line 16 def initialize(input) @command_options = [] @utility = nil @file = parse_input(input) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
53 54 55 |
# File 'lib/graphicsmagick/image.rb', line 53 def method_missing(method, *args, &block) add_option("-#{method.to_s.gsub(/_/,'-')}", *args) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/graphicsmagick/image.rb', line 12 def file @file end |
Instance Method Details
#path ⇒ Object
Returns the path of the associated file
24 25 26 |
# File 'lib/graphicsmagick/image.rb', line 24 def path @file.path end |
#write(output, opts = {}) ⇒ Object
Writes the changes to the file specified in output
. Set :timeout => 30.seconds to change the timeout value. Default is one minute.
30 31 32 33 34 35 36 37 38 |
# File 'lib/graphicsmagick/image.rb', line 30 def write output, opts={} output_path = parse_input(output, false) FileUtils.copy_file(self.path, output_path) unless requires_output_file? command = build_command(output_path) run(command, opts) GraphicsMagick::Image.new(output_path) end |
#write!(opts = {}) ⇒ Object
Writes the changes to the current file. Set :timeout => 30.seconds to change the timeout value. Default is one minute.
43 44 45 46 47 48 49 |
# File 'lib/graphicsmagick/image.rb', line 43 def write! opts={} raise NoMethodError, "You cannot use Image#write(output) with the #{current_utility} command" if requires_output_file? command = build_command(path) run(command, opts) self end |