Class: Nutils::Filters::Crop
- Inherits:
-
Nanoc3::Filter
- Object
- Nanoc3::Filter
- Nutils::Filters::Crop
- Defined in:
- lib/nutils/filters/crop.rb
Overview
Note:
Requires «RMagick»
Instance Method Summary collapse
-
#run(filename, opts = {}) ⇒ File
Runs the content through RMagick#crop.
Instance Method Details
#run(filename, opts = {}) ⇒ File
Runs the content through RMagick#crop.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nutils/filters/crop.rb', line 33 def run(filename, opts = {}) require 'RMagick' raise ArgumentError, "x, y, width and height are required parameters." unless opts[:x] and opts[:y] and opts[:width] and opts[:height] image = Magick::ImageList.new filename width = eval(opts[:width].to_s) height = eval(opts[:height].to_s) image.crop(opts[:x], opts[:y], width, height).write output_filename rescue Exception => e raise ArgumentError, "#{e}\nSome parameters cannot be promoted to Integer." end |