Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CarrierWave and resize to a specific width

Using CarrierWave in Rails 3.0 how would you go about making the code resize images that have a width larger than 500 pixels to be 500 pixels wide and adjust the height appropriately - keeping the same initial ratio of width to height.

like image 501
BuddyJoe Avatar asked Aug 25 '11 17:08

BuddyJoe


2 Answers

You Can use:

process :resize_to_limit => [500, nil] 
like image 194
William Wong Garay Avatar answered Sep 19 '22 17:09

William Wong Garay


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.

like image 30
Jason Yost Avatar answered Sep 23 '22 17:09

Jason Yost