Skip to content

Instantly share code, notes, and snippets.

@andykorth
Created October 1, 2014 21:43
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 andykorth/c20fe488a973e76dd410 to your computer and use it in GitHub Desktop.
Save andykorth/c20fe488a973e76dd410 to your computer and use it in GitHub Desktop.
Use imageconvert to make icons.
def system(cmd)
puts cmd
Kernel.system(cmd)
end
def convert(filename, size)
ext = File.extname(filename)
base = File.basename(filename, ext)
dir = File.dirname(filename)
# download imageconvert here: https://github.com/slembcke/ImageConvert
system "./imageconvert #{size} #{filename} #{File.join(dir, "Icon-" + size.to_s + ".png")}"
end
filename = ARGV[0]
# You could glob it too: (Dir.glob(ARGV[0])).each do|filename|
convert(filename, 29)
convert(filename, 40)
convert(filename, 50)
convert(filename, 58)
convert(filename, 57)
convert(filename, 72)
convert(filename, 76)
convert(filename, 80)
convert(filename, 100)
convert(filename, 114)
convert(filename, 120)
convert(filename, 144)
convert(filename, 152)
convert(filename, 180)
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment