Skip to content

Instantly share code, notes, and snippets.

@sophistifunk
Created July 2, 2012 10:29
Show Gist options
  • Save sophistifunk/3032530 to your computer and use it in GitHub Desktop.
Save sophistifunk/3032530 to your computer and use it in GitHub Desktop.
Create a bunch of resized icons for iOS projects
#!/usr/bin/ruby
# Takes one large image (say, 512 or 1024 px) and creates some iOS icons:
#
# Icon-72.png
# Icon-Small-50.png
# Icon-Small.png
# Icon-Small@2x.png
# Icon.png
# Icon@2x.png
require 'rubygems'
require 'image_science'
unless ARGV.length == 1
print "usage: make-ios-icons.rb big-ass-image.png\n"
exit
end
names = %w{Icon-72.png Icon-72@2x.png Icon-Small-50.png Icon-Small.png Icon-Small@2x.png Icon.png Icon@2x.png}
sizes = [72, 144, 50, 29, 58, 57, 114]
ImageScience.with_image(ARGV[0]) do |img|
sizes.zip(names).each do |size_name|
img.resize(size_name[0], size_name[0]) do |img2|
img2.save size_name[1]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment