mostly finished port to ruby3

This commit is contained in:
Kyle Drake 2022-08-10 14:31:36 -05:00
parent a9dd102383
commit 0ca1473d22
30 changed files with 765 additions and 731 deletions

View file

@ -50,14 +50,14 @@ class ScreenshotWorker
return false
end
img_list.new_image(img_list.first.columns, img_list.first.rows) { self.background_color = "white" }
img_list.new_image(img_list.first.columns, img_list.first.rows) {|i| i.background_color = "white" }
img = img_list.reverse.flatten_images
img_list.destroy!
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
screenshot_path = File.join user_screenshots_path, File.dirname(path)
FileUtils.mkdir_p screenshot_path unless Dir.exists?(screenshot_path)
FileUtils.mkdir_p screenshot_path unless Dir.exist?(screenshot_path)
Site::SCREENSHOT_RESOLUTIONS.each do |res|
width, height = res.split('x').collect {|r| r.to_i}
@ -72,7 +72,7 @@ class ScreenshotWorker
tmpfile_path = "/tmp/#{SecureRandom.uuid}.jpg"
begin
new_img.write(tmpfile_path) { self.quality = 92 }
new_img.write(tmpfile_path) { |i| i.quality = 92 }
new_img.destroy!
$image_optim.optimize_image! tmpfile_path
File.open(full_screenshot_path, 'wb') {|file| file.write File.read(tmpfile_path)}

View file

@ -43,8 +43,8 @@ class ThumbnailWorker
full_thumbnail_path = File.join(user_thumbnails_path, "#{path}.#{res}.#{save_ext}")
resimg.write(full_thumbnail_path) {
self.quality = 75
resimg.write(full_thumbnail_path) { |i|
i.quality = 75
}
resimg.destroy!
#$image_optim.optimize_image! full_thumbnail_path