Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you reprocess different versions of an image in Carriewave?

I created 3 versions of my Avatar:

process :resize_to_limit => [400, 400]  

   version :big_thumb do
     process :resize_to_limit => [80, 80]
   end

   version :small_thumb do
     process :resize_to_limit => [50, 50]
   end

I wrote a crop function to crop my original version, which works, but I can't seem to regenerate my 2 thumbnails based off of that newly cropped original version.

Any ideas?

like image 477
Jonathan Chiu Avatar asked Feb 27 '11 10:02

Jonathan Chiu


1 Answers

Sorry if this is not what you're looking for but, I took this from the carrierwave docs

Recreating versions

You might come to a situation where you want to retroactively change a version or add a new one. You can use the recreate_versions! method to recreate the versions from the base file. This uses a naive approach which will re-upload and process all versions.

instance = MyUploader.new
instance.recreate_versions!

Or on a mounted uploader:

User.all.each do |user|
  user.avatar.recreate_versions!
end
like image 200
stephenmurdoch Avatar answered Nov 02 '22 13:11

stephenmurdoch