19

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?

qendu
  • 289
  • 2
  • 5
  • 12

2 Answers2

36

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.

Konrad Szczęśniak
  • 1,960
  • 1
  • 14
  • 13
2

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

Mohibeyki
  • 459
  • 6
  • 16