CarrierWave and resize to a specific width CarrierWave and resize to a specific width ruby-on-rails ruby-on-rails

CarrierWave and resize to a specific width


You Can use:

process :resize_to_limit => [500, nil]


process :resize_to_limit => [500, 0]

This will process the image to be no wider than 500px while retaining the proper aspect ratio and allowing any height.


I know this is an old question, but I needed something similar.

I wanted images to be resized if they were larger than a given size, but not scaled up if they were smaller.

resize_to_limit(width, height)

Resize the image to fit within the specified dimensions while retaining the original aspect ratio. Will only resize the image if it is larger than the specified dimensions. The resulting image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.

Details: http://carrierwave.rubyforge.org/rdoc/classes/CarrierWave/MiniMagick.html#M000051