Skip to content

Commit

Permalink
Added rake task for optimizing images
Browse files Browse the repository at this point in the history
  • Loading branch information
avdgaag committed Jun 2, 2011
1 parent bd81509 commit f9158d5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tasks/crush.rake
@@ -0,0 +1,16 @@
namespace :crush do
task :png do
sh 'pngcrush -q -e .crushed -rem time -rem alla -rem allb -l 9 -w 32 -plte_len 0 -reduce -rem gAMA -rem cHRM -rem iCCP -rem sRGB -brute output/**/*.png'
sh 'find output -name "*.crushed" -print | sed "s/\\(.*\\)\\.crushed/ & \\1.png/" | xargs -L1 mv'
end

task :jpg do
FileList['output/**/*.jpg'].each do |input_file|
sh "jpegtran -copy none -optimize -progressive -outfile #{input_file.sub(/jpg$/, 'crushed')} #{input_file}"
sh 'find output -name "*.crushed" -print | sed "s/\\(.*\\)\\.crushed/ & \\1.jpg/" | xargs -L1 mv'
end
end
end

desc 'Optimize images in output directory'
task :crush => [:'crush:png', :'crush:jpg']

0 comments on commit f9158d5

Please sign in to comment.