lib/middleware/crop.rb in tracksperanto-2.9.5 vs lib/middleware/crop.rb in tracksperanto-2.9.6

- old
+ new

@@ -1,9 +1,16 @@ # -*- encoding : utf-8 -*- # Does the same as the Pad middleware but with absolute pixel values instead of fractionals class Tracksperanto::Middleware::Crop < Tracksperanto::Middleware::Base - attr_accessor :top, :left, :right, :bottom - cast_to_int :top, :left, :right, :bottom + + parameter :top, :cast => :int, :desc => "Top crop amount in px" + parameter :left, :cast => :int, :desc => "Left crop amount in px" + parameter :right, :cast => :int, :desc => "Right crop amount in px" + parameter :bottom, :cast => :int, :desc => "Bottom crop amount in px" + + def self.action_description + "Crop or pad the image by a specified number of pixels" + end def start_export(w, h) left_pad, right_pad, top_pad, bottom_pad = (left / w.to_f), (right / w.to_f), (top / h.to_f), (bottom / h.to_f) @pad = Tracksperanto::Middleware::Pad.new(@exporter, :left_pad => left_pad, :right_pad => right_pad, :top_pad => top_pad, :bottom_pad => bottom_pad) @pad.start_export(w, h)