This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/lib/tasks/images.rake
Loïc Guitaut 008b700a3f DEV: Upgrade to Rails 7
This patch upgrades Rails to version 7.0.2.4.
2022-04-28 11:51:03 +02:00

16 lines
387 B
Ruby

# frozen_string_literal: true
require "file_helper"
task "images:compress" => :environment do
images = Dir.glob("#{Rails.root}/app/**/*.png")
image_sizes = images.map { |i| [i, File.size(i)] }.to_h
images.each do |path|
if FileHelper.optimize_image!(path)
new_size = File.size(path)
puts "#{path} => from: #{image_sizes[path]} to: #{new_size}"
end
end
end