Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined Method Scale In CarrierWave

I'm trying to use this code in my uploader

  version :thumb do
    process :scale => [50, 50]
  end

and I get an error saying

undefined method `scale' for #<#<Class:0x235b680>:0x0fb4c8>

I'm using Carrierwave with MiniMagick. How can I fix this error?

like image 612
qendu Avatar asked Mar 30 '12 22:03

qendu


2 Answers

Instead of calling scale call resize_to_fit

process :resize_to_fit => [50, 50]

or resize_to_fill if you dont want to keep aspect ratio

EDIT

My bad, both resize_to_fit and resize_to_fill are keeping the aspect ratio.

The difference is that resize_to_fit will keep whole image in given bounds, and resize_to_fill will fill whole given area so it can cut your image when necessary.

like image 84
Konrad Szczęśniak Avatar answered Oct 15 '22 03:10

Konrad Szczęśniak


The scale method is an example (generated by carrierwave in uploader) you need to use RMagic (or minimagick) functions (in their own gem, since smaller version of them is included in carrierwave) if you want to scale and therefor, not preserve the original image's ratio

like image 33
Mohibeyki Avatar answered Oct 15 '22 03:10

Mohibeyki