Skip to content

Instantly share code, notes, and snippets.

@matt-west
Created April 18, 2012 15:54
Show Gist options
  • Save matt-west/2414491 to your computer and use it in GitHub Desktop.
Save matt-west/2414491 to your computer and use it in GitHub Desktop.
Ruby Script for Optimizing JPEGs with jpegtran
#!/usr/bin/env ruby
files = Array.new
Dir.new(Dir.pwd).entries.each { |n| files.push(n) if File.file?(n) }
files.each do |file|
if file =~ /jpg|JPG:/i
system "jpegtran -copy none -optimize -outfile #{file} #{file}"
print "optimized #{file}\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment