Skip to content

Instantly share code, notes, and snippets.

@lite
Created February 5, 2013 09:48
Show Gist options
  • Save lite/4713392 to your computer and use it in GitHub Desktop.
Save lite/4713392 to your computer and use it in GitHub Desktop.
Save scratch file(*.sb) to thumbnail.png
#!/usr/bin/env python
# coding=utf-8
# pip install kurt
# python thumb.py 3013900.sb
import sys
import kurt
from kurt.files import ScratchProjectFile, ScratchSpriteFile
def save_thumb(project):
project.load()
thumb = project.info["thumbnail"]
if thumb:
thumb.save("thumbnail.png")
if __name__ == '__main__':
if len(sys.argv) < 2:
exit
project = ScratchProjectFile(sys.argv[1], load=False)
try:
save_thumb(project)
except FolderExistsException, e:
print "Folder exists: %s" % unicode(e)
except FileNotFoundException, e:
print "File missing: %s" % unicode(e)
except InvalidProject, e:
print "Invalid project: %s" % unicode(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment