discourse/lib/tasks/images.rake
Jarek Radosz 48691ee582
DEV: Enable Rails/FilePath rubocop rule (#40097)
(to be enabled in the shared config)
2026-05-19 19:07:54 +02:00

15 lines
395 B
Ruby
Vendored

# frozen_string_literal: true
require "file_helper"
task "images:compress" => :environment do
images = Dir.glob("#{Rails.root.join("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