FIX: images:compress rake task
Optimized a few unoptimized PNGs.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 882 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1021 B After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 895 B |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
|
@ -2,11 +2,12 @@ require_dependency "file_helper"
|
|||
|
||||
task "images:compress" => :environment do
|
||||
images = Dir.glob("#{Rails.root}/app/**/*.png")
|
||||
image_sizes = Hash[*images.map { |i| [i, File.size(i)] }.to_a.flatten]
|
||||
FileHelper.optimize_images!(images) do |name, optimized|
|
||||
if optimized
|
||||
new_size = File.size(name)
|
||||
puts "#{name} => from: #{image_sizes[name.to_s]} to: #{new_size}"
|
||||
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
|
||||
|
|