Using Carrierwave, I created 3 versions of an avatar - an original, a small_thumb and a large_thumb using the following lines:
process :resize_to_limit => [40
I haven't tried but maybe putting something like.
def reprocess_image
image.reprocess(crop_x,crop_y,crop_w,crop_h)
image.recreate_versions!
end
You need to call image.cache_stored_file!
before calling recreate_versions!
It's weird because the method itself calls that if the file is cached, but for some reason it wasn't working.
So that would be something like:
def reprocess_image
image.reprocess(crop_x, crop_y, crop_w, crop_h)
image.cache_stored_file!
image.recreate_versions!
end
Try
image.recreate_versions!
Sorry, on the bus. I can't expound on that.
check this latest RailsCast:
http://railscasts.com/episodes/182-cropping-images-revised
after cropping one version of the image, you can then either calculate the cropping coordinates for the other versions, or probably easier, scale down the cropped image with the same aspect ratios as the other versions of the original image
This HowTo was most helpful for me (even if I don't use fog):
https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-Recreate-and-reprocess-your-files-stored-on-fog
I added a reprocess method on my model and then called it in for each loop in my rake task:
def reprocess
begin
self.process_photo_upload = true
self.photo.cache_stored_file!
self.photo.retrieve_from_cache!(photo.cache_name)
self.photo.recreate_versions!
self.save!
rescue => e
STDERR.puts "ERROR: MyModel: #{id} -> #{e.to_s}"
end
end
Rake:
task :reprocess_photos => :environment do
MyModel.all.each{|mm| mm.reprocess}
end
PS: Rails 4.2