Skip to content

Instantly share code, notes, and snippets.

@FreeSlave
Last active December 13, 2017 16:06
Show Gist options
  • Select an option

  • Save FreeSlave/6ce18ec46c9cd70087b2c7a55d69e4f8 to your computer and use it in GitHub Desktop.

Select an option

Save FreeSlave/6ce18ec46c9cd70087b2c7a55d69e4f8 to your computer and use it in GitHub Desktop.
Python PIL script to generate tga from ico
#!/usr/bin/python
import sys
import os.path
from PIL import Image
loadpath = 'game.ico'
if len(sys.argv) > 1:
loadpath = sys.argv[1]
savepath = os.path.splitext(loadpath)[0] + '.tga'
if len(sys.argv) > 2:
savepath = sys.argv[2]
icon = Image.open(loadpath)
size = (64,64)
if icon.size[0] < 64:
size = icon.size
icon.info["orientation"] = 1
icon.resize(size).save(savepath, 'TGA')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment