new rake task for generating resized images
This commit is contained in:
3843
danbooru.struct.sql
3843
danbooru.struct.sql
File diff suppressed because it is too large
Load Diff
42
lib/tasks/images.rake
Normal file
42
lib/tasks/images.rake
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace :images do
|
||||
desc "Generate medium-sized images of posts"
|
||||
task :generate_medium => :environment do
|
||||
Post.where("width > ?", Danbooru.config.medium_image_width).find_each do |post|
|
||||
if post.is_image?
|
||||
puts "resizing medium #{post.id}"
|
||||
Danbooru.resize(post.file_path, post.medium_file_path, Danbooru.config.medium_image_width, nil, 90)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Generate large-sized images of posts"
|
||||
task :generate_large => :environment do
|
||||
Post.where("width > ?", Danbooru.config.large_image_width).find_each do |post|
|
||||
if post.is_image?
|
||||
puts "resizing large #{post.id}"
|
||||
Danbooru.resize(post.file_path, post.large_file_path, Danbooru.config.large_image_width, nil, 90)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Distribute medium posts to other servers"
|
||||
task :distribute_medium => :environment do
|
||||
Post.where("width > ?", Danbooru.config.medium_image_width).find_each do |post|
|
||||
if post.is_image?
|
||||
puts "distributing medium #{post.id}"
|
||||
RemoteFileManager.new(post.medium_file_path).distribute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Distribute large posts to other servers"
|
||||
task :distribute_large => :environment do
|
||||
Post.where("width > ?", Danbooru.config.large_image_width).find_each do |post|
|
||||
if post.is_image?
|
||||
puts "distributing large #{post.id}"
|
||||
RemoteFileManager.new(post.large_file_path).distribute
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
9
script/setup_directories.sh
Normal file
9
script/setup_directories.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# this should be run after the initial capistrano deployment
|
||||
|
||||
mv /var/www/danbooru/public/data/sample /var/www/danbooru/shared/large
|
||||
mv /var/www/danbooru/public/data/preview /var/www/danbooru/shared/preview
|
||||
mv /var/www/danbooru/public/data /var/www/danbooru/shared/original
|
||||
mkdir -p /var/www/danbooru/shared/medium
|
||||
|
||||
Reference in New Issue
Block a user