Last active
September 11, 2016 06:02
-
-
Save uberbruns/9916166 to your computer and use it in GitHub Desktop.
iOS Retina Assets Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
path = ARGV[0] | |
ok = 0 | |
fail = 0 | |
Dir.glob("#{path}/*.png", File::FNM_DOTMATCH) do |f| | |
unless f.end_with? "@2x.png" | |
s2_f = File.basename(f, ".png") + "@2x.png"; | |
s2_f = File.join(path, s2_f) | |
if File.exist?(s2_f) | |
s1_x, s1_y = IO.read(f)[0x10..0x18].unpack('NN') | |
s2_x, s2_y = IO.read(s2_f)[0x10..0x18].unpack('NN') | |
if s1_x*2 == s2_x && s1_y*2 == s2_y | |
ok = ok + 1 | |
else | |
puts "Bad Dimensions: #{s2_f}; Found: #{s2_x}x#{s2_y}; Expected: #{s1_x*2}x#{s1_y*2}" | |
fail = fail + 1 | |
end | |
else | |
puts "Missing File: #{s2_f}" | |
fail = fail + 1 | |
end | |
end | |
end if File.directory?(path) | |
puts "OK: #{ok}; Fail: #{fail}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: