2
votes

I am having some issues with my rails/carrierwave. Specifically with my thumbnail resize. For some reason it is not resizing the thumbnails for me. This is the my uploader class:

class AvatarUploader < CarrierWave::Uploader::Base
 include CarrierWave::RMagick

 storage :file

 def store_dir
   "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
 end

 version :thumb do
   process :resize_to_limit => [250, 250]
 end
end

I have included carrierwave and rmagick gems in the Gemfile and I am currently using Ruby 1.9.3 and Rails 3.2.13 This is how I am planning to show my images.

<ul class="small-block-grid-2 medium-block-grid-3 large-block-grid-4">
 <% for modeling in @modelings %>
  <li>
   <%= image_tag modeling.image_url(:thumb) if modeling.image? %>
  </li>
 <% end %>
</ul>

It seems that the images are being resized however not to the specific 250 params I've set for it. Also a side question, if the resizing should work, will it resize horizontal and vertical images to the same thumbnail size?

Thanks, this has been a real pain for me, any help would be great!

1

1 Answers

0
votes

Run a scaling process as the file is uploaded.

This is what I am doing for my application and it works great!

 process :scale => [608, 405]
   #
 def scale(width, height)
   manipulate! do |img|
      img = img.scale(608,405)
   end
 end

 version :preview do
    process :resize_to_fit => [300, 200]
 end

 version :search_thumbnail, :from_version => :preview do
    process :resize_to_fit => [150, 100]
 end