This has been a long-standing problem for me which I never took the
time to look into. But I just made a new uploader for avatars on a
new mac and it is still filling instead of fitting. I begin with a
105x80 pic and end up with a 630x480 pic using this uploader:
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be
mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{
model.id}"
end
# Provide a default URL as a default if there hasn't been a file
uploaded:
def default_url
'/images/no-photo-thumb.png'
end
# Process files as they are uploaded:
process :resize_to_fit => [640, 480]
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [40,40]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
end
end
Any ideas? I can't find anyone having similar problems so I'm
guessing it's something I'm doing.
Thanks,
-Nic