Skip to content

Instantly share code, notes, and snippets.

@uberbruns
Last active September 11, 2016 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save uberbruns/9916166 to your computer and use it in GitHub Desktop.
Save uberbruns/9916166 to your computer and use it in GitHub Desktop.
iOS Retina Assets Test
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}"
@uberbruns
Copy link
Author

Usage:

$ ruby testassets.rb /Users/karsten.bruns/Desktop/MyAssets 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment