add rake task for regenerating images

This commit is contained in:
albert
2013-02-19 22:13:07 -05:00
parent c5731298fb
commit 9e3df40b39

View File

@@ -1,6 +1,23 @@
require 'danbooru_image_resizer/danbooru_image_resizer'
namespace :images do
desc "Regenerates all images for a post id"
task :regen => :environment do
post_id = ENV["id"]
if post_id !~ /\d+/
raise "Usage: regen_img.rb POST_ID"
end
post = Post.find(post_id)
upload = Upload.new
upload.file_ext = post.file_ext
upload.image_width = post.image_width
upload.image_height = post.image_height
upload.generate_resizes(post.file_path)
post.distribute_files
end
desc "Generate thumbnail-sized images of posts"
task :generate_preview => :environment do
Post.where("image_width > ?", Danbooru.config.small_image_width).find_each do |post|