Search code examples
ruby-on-railsruby-on-rails-3rmagickminimagick

scale image only width with minimagick in ruby on rails 3


I am using this method for resize the images:

version :big do
            process :resize_to_fit => [560, 200]
            process :convert => :png
          end

But with this method I have that write a height fixed.

I want only scale or resize the width image.

I want the height of the image is automatic and scale the image to the width that has been given.

How can I scale or resize, only the width image?

I'm using minimagick with carrierwave.


Solution

  • It's actually quite easy to do this. Here's an example:

      version :column do
        process :resize_to_fit => [250, nil]
      end
    

    This version will be rescaled so that the width is the specified value (250, in my case), and will retain the aspect ratio.