Skip to content

Instantly share code, notes, and snippets.

@zef
Created December 3, 2013 18:39
Show Gist options
  • Save zef/7775017 to your computer and use it in GitHub Desktop.
Save zef/7775017 to your computer and use it in GitHub Desktop.
Prints a list of @2x assets that have odd dimensions. Requires imagemagick and the mini_magick gem.
require 'mini_magick'
root_path = '/Users/zef/Dropbox/code/some_project'
local_path = 'some_project/assets'
path = File.join(root_path, local_path, '**.png')
list = []
Dir.glob(path).each do |file|
name = File.basename(file)
image = MiniMagick::Image.open(file)
if name.match('@2x') && image[:dimensions].any? { |d| d.odd? }
list << file
puts "#{name}: #{image[:dimensions].join('x')}"
end
end
puts "Found #{list.size} odd @2x images."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment