Mini_magick resize_to_fit is filling instead of fitting

709 views
Skip to first unread message

Nic

unread,
May 23, 2011, 5:34:18 PM5/23/11
to carrierwave
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

Jonas Nicklas

unread,
May 24, 2011, 6:28:38 PM5/24/11
to carri...@googlegroups.com
Actually, you want resize_to_limit, not resize_to_fit ;)

/Jonas

> --
> You received this message because you are subscribed to the Google Groups "carrierwave" group.
> To post to this group, send email to carri...@googlegroups.com.
> To unsubscribe from this group, send email to carrierwave...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/carrierwave?hl=en.
>
>

Nic

unread,
May 25, 2011, 11:47:39 AM5/25/11
to carrierwave
Awesome thank you Jonas
Reply all
Reply to author
Forward
0 new messages