Closed fatuhoku closed 1 year ago
Pretty stumped. Now I must find another way to recreate all the versions :S
@fatuhoku yeah this is quite annoying
I found that this does work for some images and not for others. Guess I can skip over them?
# Find out the offending models...
Model.all.each{|m|m.try(:image).try(:recreate_versions!) rescue (puts m.id) }
Found out that the document uploader exists but the size of the file stored is zero. Not sure why.
Anecdotally, I found that our recreate_versions!
issue was because the file dimensions were too big. We've implemented carrierwave-bombshelter & carrierwave-imageoptimizer.
When the image exceeds 4096x4096 on some particular images we receive the:
NoMethodError: undefined method
read' for nil:NilClass`
Other times we receive the appropriate bombshelter error:
CarrierWave::IntegrityError Image size should be less than or equal to 4096x4096
I'm not sure why the read error is shown on some images while the integrity error is shown on others. If I re-crop images to be below 4096x4096 the image versions are processed without issue.
Sample code:
class BannerUploader < CarrierWave::Uploader::Base
include CarrierWave::BombShelter
include CarrierWave::MiniMagick
include CarrierWave::ImageOptimizer
process :optimize
...
# uploader details
end
Worker: due to direct-to-S3 uploads, we utilize the remote_#{column}_url
method.
class BannerWorker
def self.perform(obj_id, key)
# object info...
obj.remote_banner_url = "https://s3-bucket/#{key}"
obj.banner.recreate_versions!
end
end
I have bundled carrierwave from master (2.0.0.alpha) and stills give me the same error.
NoMethodError: undefined method
read' for nil:NilClass`
After running @fatuhoku code: Model.all.each{|m|m.try(:image).try(:recreate_versions!) rescue (puts m.id) }
, it seems that the error is caused by nil pictures.
Carrierwave version: 1.1.0. Code:
In the console: