carrierwave
https://github.com/carrierwaveuploader/carrierwave
Ruby
Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
CarrierWave::RMagick#manipulate!
Manipulate the image with RMagick. This method will load up an image
and then pass each of its frames to the supplied block. It will then
save the image to disk.
=== Gotcha
This method assumes that the object responds to +current_path+.
Any class that this module is mixed into must have a +current_path+ method.
CarrierWave::Uploader does, so you won't need to worry about this in
most cases.
=== Yields
[Magick::Image] manipulations to perform
[Integer] Frame index if the image contains multiple frames
[Hash] options, see below
=== Options
The options argument to this method is also yielded as the third
block argument.
Currently, the following options are defined:
==== :write
A hash of assignments to be evaluated in the block given to the RMagick write call.
An example:
manipulate! do |img, index, options|
options[:write] = {
:quality => 50,
:depth => 8
}
img
end
This will translate to the following RMagick::Image#write call:
image.write do |img|
self.quality = 50
self.depth = 8
end
==== :read
A hash of assignments to be given to the RMagick read call.
The options available are identical to those for write, but are passed in directly, like this:
manipulate! :read => { :density => 300 }
==== :format
Specify the output format. If unset, the filename extension is used to determine the format.
=== Raises
[CarrierWave::ProcessingError] if manipulation failed.Edit
git clone [email protected]:carrierwaveuploader/carrierwave.git
cd carrierwave
open lib/carrierwave/processing/rmagick.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-CarrierWave--RMagick-manipulate--for-pr
# Commit to gitgit add lib/carrierwave/processing/rmagick.rbgit commit -m "better docs for CarrierWave::RMagick#manipulate!"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-CarrierWave--RMagick-manipulate--for-pr
hub pull-request
# Celebrate!