carrierwave

https://github.com/jnicklas/carrierwave

Ruby

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks

CarrierWave::MiniMagick#resize_to_fill

Resize the image to fit within the specified dimensions while retaining
the aspect ratio of the original image. If necessary, crop the image in the
larger dimension.

=== Parameters

[width (Integer)] the width to scale the image to
[height (Integer)] the height to scale the image to
[gravity (String)] the current gravity suggestion (default: 'Center'; options: 'NorthWest', 'North', 'NorthEast', 'West', 'Center', 'East', 'SouthWest', 'South', 'SouthEast')

=== Yields

[MiniMagick::Image] additional manipulations to perform

Source | Google | Stack overflow

Edit

git clone [email protected]:jnicklas/carrierwave.git

cd carrierwave

open lib/carrierwave/processing/mini_magick.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-CarrierWave--MiniMagick-resize_to_fill-for-pr


# Commit to git

git add lib/carrierwave/processing/mini_magick.rbgit commit -m "better docs for CarrierWave::MiniMagick#resize_to_fill"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-CarrierWave--MiniMagick-resize_to_fill-for-pr

hub pull-request


# Celebrate!