Last active
December 27, 2015 19:14
-
-
Save patoroco/2774efff146c8cb02108 to your computer and use it in GitHub Desktop.
Script to compare retina and non-retina images to test if there are correctly sized
This file contains 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
#!/usr/bin/env ruby | |
require 'fastimage' | |
if ARGV.count != 1 | |
puts "Use command: \n$ ruby #{__FILE__} <.xcassets>" | |
exit() | |
end | |
def test_if_retina_is_par file_path | |
size_array = FastImage.size(file_path) | |
width = size_array[0] | |
height = size_array[1] | |
if (width.to_i % 2) != 0 || (height.to_i % 2) != 0 | |
puts "#{file_path} :: (#{width}, #{height})" | |
end | |
end | |
def find_coincidences(current_path, file_pattern) | |
Dir.foreach(current_path).each do |file| | |
next if file == "." || file == ".." | |
file_expanded = File.join current_path, file | |
if File.directory? file_expanded | |
find_coincidences file_expanded, file_pattern | |
next | |
end | |
if file_expanded.end_with? file_pattern | |
test_if_retina_is_par file_expanded | |
end | |
end | |
end | |
assets_path = File.expand_path(ARGV[0]) | |
find_coincidences assets_path, "@2x.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment