Skip to content

Instantly share code, notes, and snippets.

@keroxp
Created May 21, 2013 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keroxp/5619541 to your computer and use it in GitHub Desktop.
Save keroxp/5619541 to your computer and use it in GitHub Desktop.
ひとつのファイルからiOSアプリのアイコンを全部作るRubyスクリプト tiny script for making ios app icons in all sizes #USAGE ruby iosicon.rb ICON_NAME
# coding:utf-8
require "rubygems"
require "RMagick"
if !ARGV[0]
STDERR.puts "missing argument"
exit
end
if ARGV.length > 1
STDERR.puts "too many arguments : " + ARGV.length.to_s
exit
end
sizes = {
"Icon-72" => 72,
"Icon-72@2x" => 144,
"Icon-Small-50" => 50,
"Icon-Small-50@2x" => 100,
"Icon-Small" => 29,
"Icon-Small@2x" => 58,
"Icon" => 57,
"Icon@2x" => 114,
"iTunesArtwork" => 512,
"iTunesArtwork@2x" => 1024
}
begin
image_list = Magick::ImageList.new ARGV[0]
rescue => e
STDERR.puts e
exit
end
if image_list.format != "PNG"
STDERR.puts "file is not png"
exit
end
if image_list.columns != image_list.rows
STDERR.puts "image is not square"
exit
end
sizes.each_key{|key|
s = sizes[key]
image_list.resize(s,s).write(key+".png")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment