Skip to content

Instantly share code, notes, and snippets.

@GamingasCZ
Created January 6, 2024 18:52
Show Gist options
  • Save GamingasCZ/e18468c633ee4762630ed79a3c325620 to your computer and use it in GitHub Desktop.
Save GamingasCZ/e18468c633ee4762630ed79a3c325620 to your computer and use it in GitHub Desktop.
Splits all Geometry Dash icon spritesheets, standing in its way!
import os, plistlib, json
from PIL import Image
plists = list(filter(lambda x: x.endswith(".plist"), os.listdir()))
for icon in plists:
with open(icon, "rb") as f:
xml = plistlib.load(f, fmt=plistlib.FMT_XML)
filename = xml["metadata"]["textureFileName"].split("/")[1]
for key, value in xml["frames"].items():
im = Image.open(filename)
size = [int(float(i)) for i in value["textureRect"][2:-2].replace("},{",",").split(",")]
box = (size[0], size[1], size[0]+size[2], size[1]+size[3])
region = im.crop(box)
if (value["textureRotated"]):
region = region.rotate(90)
newIm = Image.new("RGBA",(size[2], size[3]))
newIm.paste(region, (0,0))
newIm.save("ex/"+key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment