I tried to set up for uploading photos with my rails app. However, the carrierwave uploader does not resize the photos being uploaded. When I do not call the resize_to_fill function, the photos are uploaded perfectly. Any advice?
When a photo is submitted with resize_to_fill, the error 'failed to be processed' is returned. How can i fix it?
I guess I need to 'require' 'carrierwave/processing/mini_magick' for calling resize_to_fill, but i don't know where to put this file.
gemfile
"carrierwave", "0.4.10"
"mini_magick", "3.2.1"
"rails", "2.3.14"
Platform
win7 64bit
ruby 1.8.7
imagemagick (path = C:ImageMagick-6.7.2-Q16)
batterhead
thanks for your reply. Below is my coding, please advise.
i'm just thinking does the problem come from my combination of win7 + imagemagick + mini_magick + carrierwave? such a problem should have been reproduced easily by many people, i guess. are those versions incompatible with each other?
i just tested my application and tried to upload a photo again. a processing_error returned:
Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: Command ("identify -ping C:/Users/User/mini_magick20111018-4296-f18lsi-0.jpg") failed: {:output=>"'identify' 244243254O244272263241251Υ~263241251R245O241B............", :status_code=>1}
of course the jpg was not created in C:/Users/User folder. please help.
{avatar_uploader.rb}
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :resize_to_fill => [320, 240]
def extension_white_list
%w(jpg jpeg gif png)
end
end
{event_photo.rb}
class EventPhoto < ActiveRecord::Base
attr_accessible :event_id, :avatar, :created_by, :updated_by
belongs_to:event
mount_uploader :avatar, AvatarUploader
end
{preinitializer.rb}
begin
require 'rubygems'
require 'bundler'
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…