add opengraph / link expander friendly screenshot, add image optimizers

This commit is contained in:
Kyle Drake 2023-12-05 15:49:14 -06:00
parent 3c62b7be22
commit c3789564f0
3 changed files with 10 additions and 0 deletions

View file

@ -54,8 +54,15 @@ class ScreenshotWorker
screenshot_path = File.join user_screenshots_path, File.dirname(path_for_screenshot)
FileUtils.mkdir_p screenshot_path unless Dir.exist?(screenshot_path)
ImageOptimizer.new(base_image_tmpfile_path, level: 1).optimize
FileUtils.cp base_image_tmpfile_path, File.join(user_screenshots_path, "#{path_for_screenshot}.png")
# Optimized for open graph link expanders
image = Rszr::Image.load base_image_tmpfile_path
image.resize! 1200, 630, crop: :n
image.save File.join(user_screenshots_path, "#{path_for_screenshot}.jpg"), quality: 85
ImageOptimizer.new(File.join(user_screenshots_path, "#{path_for_screenshot}.jpg")).optimize
Site::SCREENSHOT_RESOLUTIONS.each do |res|
width, height = res.split('x').collect {|r| r.to_i}