before you run this script, you should had ruby env and Xcode.
1. save it with name ‘png’
2. chmod +x png
useage: ./png [ipa file path]


#!/usr/bin/env ruby -wKU
require 'rubygems'
ipa = ARGV.first
puts "useage:png " and return if !ipa or ipa.end_with?("ipa")
name = File.basename(ipa, ".ipa")
# create output folder in you desktop
output = "#{ENV['HOME']}/Desktop/#{name}"
system %Q{mkdir -p "#{output}" && unzip "#{ipa}" -u -d "#{output}"}
Dir.glob(File.join(output, "**", "*.png")).each do |f|
  system %Q{/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -revert-iphone-optimizations -q "#{f}" "#{File.join(output ,File.basename(f))}"}
end
system %Q{find '#{output}' -type f -not \\( -iname "*.png" -or -iname "*.jpg" -or -iname "*.jpeg" \\) -delete}
system %Q{open "#{output}" -a finder}

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 { joycodes blog } Suffusion theme by Sayontan Sinha