carrierwave
https://github.com/jnicklas/carrierwave
Ruby
Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
CarrierWave::MiniMagick#resize_and_pad
Resize the image to fit within the specified dimensions while retaining the original aspect ratio. If necessary, will pad the remaining area with the given color, which defaults to transparent (for gif and png, white for jpeg). See http://www.imagemagick.org/script/command-line-options.php#gravity for gravity options. === Parameters [width (Integer)] the width to scale the image to [height (Integer)] the height to scale the image to [background (String, :transparent)] the color of the background as a hexcode, like "#ff45de" [gravity (String)] how to position the image === Yields [MiniMagick::Image] additional manipulations to perform
Edit
git clone [email protected]:jnicklas/carrierwave.git
cd carrierwave
open lib/carrierwave/processing/mini_magick.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-CarrierWave--MiniMagick-resize_and_pad-for-pr
# Commit to gitgit add lib/carrierwave/processing/mini_magick.rbgit commit -m "better docs for CarrierWave::MiniMagick#resize_and_pad"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-CarrierWave--MiniMagick-resize_and_pad-for-pr
hub pull-request
# Celebrate!