Skip to content

Instantly share code, notes, and snippets.

@somebox
Created November 25, 2009 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somebox/242711 to your computer and use it in GitHub Desktop.
Save somebox/242711 to your computer and use it in GitHub Desktop.
downsample attachment_fu images, rake task
# downsample large attachment_fu images
namespace :images do
desc "Downsample Large Images"
task :downsample_large => :environment do
count = Image.large.count # named scope
chunk_size = 500
(0...(count/chunk_size)).each do |i|
images = Image.large.find(:all, :offset=>i*chunk_size, :limit=>chunk_size).each do |image|
image.downsample!(55)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment