I use a method that rebuilds in my attachment model class:
# use attachment_fu protected methods to remake thumbs
def remake_thumbnails!
self.thumbnails.each {|thumb| thumb.destroy}
temp_file = create_temp_file
attachment_options[:thumbnails].each do |suffix, size|
self.create_or_update_thumbnail(temp_file, suffix, *size)
end
end
If you want a rake task, just loop through all your attachment records
and call it. I''m using something similar to this:
namespace :images do
desc "Rebuild all thumb images made by attachment_fu"
task :rebuild_thumbnails => :environment do
conditions = "(whatever you need)"
count = Image.count(:all, :conditions => conditions) # image is an
attachment_fu model
done = 0
chunk_size = 500
(0...(count/chunk_size)).each do |i|
Image.find(:all, :offset => i*chunk_size, :limit =>
chunk_size, :conditions => conditions).each do |image|
done = done + 1
# next if image.id < 46520 # to resume a stopped run
image.remake_thumbnails!
percent = "%.2f" % ((done/count.to_f)*100)
puts "#{i.id} #{percent}% done"
end
end
end
On Nov 26, 3:47 pm, eugenio
<eugenio.mode...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> i''m using this plugin for files and images uploads.
> it has a very useful feature that generatethumbnailsof every
> uploaded image, based on the geometry given in the model definition.
> now i want to change the size of one of the thumbnail: how can i re-
> generate them for the already saved image?
>
> i found thishttp://github.com/kete/kete/blob/master/lib/tasks/tools.rake
> but i don''t understand how to use it.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.