Skip to content

Instantly share code, notes, and snippets.

@luisparravicini
Created October 31, 2011 17:13
Show Gist options
  • Save luisparravicini/1328035 to your computer and use it in GitHub Desktop.
Save luisparravicini/1328035 to your computer and use it in GitHub Desktop.
Revert optimizations made on .png files for iOS and leave them on their corresponding directory (if all the png are in a single dir, use pngcrush -d instead).
require 'fileutils'
include FileUtils
$dir = ARGV.shift
if $dir.nil?
puts "usage: #{$0} <dir>"
exit 1
end
Dir.glob("#{$dir}/**/*.png").each do |path|
tmp_path = path + '.tmp'
out = `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -revert-iphone-optimizations "#{path}" "#{tmp_path}" 2>&1`
raise "error: #{out}" unless $?.success?
mv(tmp_path, path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment