Skip to content

Commit

Permalink
Added convenient macro style class methods to rmagick processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Jun 11, 2009
1 parent 12ec2bc commit 907cf4b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Version 0.2.5

* [added] Added convenient macro style class methods to rmagick processing

# Version 0.2.4

* [added] `resize_to_limit` method for rmagick
* [added] Now deletes files from Amazon S3 when record is destroyed

# Version 0.2.2

* [changed] Mount now no longer returns nil if there is no stored file, it returns a blank uploader instead
Expand Down
31 changes: 31 additions & 0 deletions lib/carrierwave/processing/rmagick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,37 @@ module CarrierWave
#
module RMagick

def self.included(base)
super
base.extend(ClassMethods)
end

module ClassMethods
def convert(format)
process :resize_to_limit => format
end

def resize_to_limit(width, height)
process :resize_to_limit => [width, height]
end

def resize_to_fit(width, height)
process :resize_to_fit => [width, height]
end

def resize_to_fill(width, height)
process :resize_to_fill => [width, height]
end

def resize_and_pad(width, height)
process :resize_to_fit => [width, height]
end

def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)
process :resize_and_pad => [width, height, background, gravity]
end
end

##
# Changes the image encoding format to the given format
#
Expand Down

0 comments on commit 907cf4b

Please sign in to comment.