mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
add opengraph / link expander friendly screenshot, add image optimizers
This commit is contained in:
parent
3c62b7be22
commit
c3789564f0
3 changed files with 10 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -63,6 +63,7 @@ gem 'twilio-ruby'
|
||||||
gem 'phonelib'
|
gem 'phonelib'
|
||||||
gem 'dnsbl-client'
|
gem 'dnsbl-client'
|
||||||
gem 'minfraud'
|
gem 'minfraud'
|
||||||
|
gem 'image_optimizer' # apt install optipng jpegoptim
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
|
|
|
@ -142,6 +142,7 @@ GEM
|
||||||
image_optim_pack (0.9.1.20221104-x86_64-linux)
|
image_optim_pack (0.9.1.20221104-x86_64-linux)
|
||||||
fspath (>= 2.1, < 4)
|
fspath (>= 2.1, < 4)
|
||||||
image_optim (~> 0.19)
|
image_optim (~> 0.19)
|
||||||
|
image_optimizer (1.9.0)
|
||||||
image_size (3.2.0)
|
image_size (3.2.0)
|
||||||
in_threads (1.6.0)
|
in_threads (1.6.0)
|
||||||
io-extra (1.4.0)
|
io-extra (1.4.0)
|
||||||
|
@ -362,6 +363,7 @@ DEPENDENCIES
|
||||||
http
|
http
|
||||||
image_optim
|
image_optim
|
||||||
image_optim_pack
|
image_optim_pack
|
||||||
|
image_optimizer
|
||||||
io-extra
|
io-extra
|
||||||
ipaddress
|
ipaddress
|
||||||
json (>= 2.3.0)
|
json (>= 2.3.0)
|
||||||
|
|
|
@ -54,8 +54,15 @@ class ScreenshotWorker
|
||||||
screenshot_path = File.join user_screenshots_path, File.dirname(path_for_screenshot)
|
screenshot_path = File.join user_screenshots_path, File.dirname(path_for_screenshot)
|
||||||
FileUtils.mkdir_p screenshot_path unless Dir.exist?(screenshot_path)
|
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")
|
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|
|
Site::SCREENSHOT_RESOLUTIONS.each do |res|
|
||||||
width, height = res.split('x').collect {|r| r.to_i}
|
width, height = res.split('x').collect {|r| r.to_i}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue