问题
I have the following file uploader
class ItemImageUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
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
asset_path("fallback/" + [version_name, "image.png"].compact.join('_'))
end
def cache_dir
"uploads/tmp"
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [80,80]
end
def extension_white_list
%w(jpg jpeg gif png)
end
Picture class
class Picture < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
mount_uploader :image, ItemImageUploader
process_in_background :image
validates_presence_of :image
def copy
Picture.new(:image => self.image)
end
And the following config in carrier_wave.rb initialization file:
CarrierWave.configure do |config|
config.enable_processing = true
#config.permissions = 0666
#config.directory_permissions = 0777
config.storage = :file
end
Images uploaded properly, but no thumbnails created, no errors occurred. Please advise.
回答1:
Just hit my head against this one myself. As the comments suggest, using carrierwave_backgrounder
causes this problem. You can see it in their documentation:
process_in_background - This stores the original file with no processing/versioning.
Doesn't help with a solution, but I thought I'd verify the problem.
回答2:
I struggled with this for a couple of hours today, because I had the same issue. Uploading of the original version would work, but it was not resized. It was working locally, but not on my production machine. Hope someone with the same issues stumbles on this answer and saves some time.
Turned out that my version of ImageMagick was not build with the correct delegates, this was the output of $ convert -version
:
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-08-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): zlib
I used this answer to install the delegates and build a fresh version of ImageMagick: ImageMagick missing decode delegates
After that, pulled up the ImageMagick info with $ convert -version
:
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-08-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib djvu fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib
And now I'm rollin'!
来源:https://stackoverflow.com/questions/12097667/rails-carrierwave-versions-are-not-created-for-some-reason