Created
September 21, 2024 15:42
-
-
Save Rorythedev/3283f762f365304ed111804a3315b7da to your computer and use it in GitHub Desktop.
a texture pack for GD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from PIL import Image | |
def create_texture_pack(pack_name, image_folder, output_folder): | |
""" | |
Create a Geometry Dash texture pack. | |
Parameters: | |
pack_name (str): The name of the texture pack. | |
image_folder (str): The path to the folder containing the images. | |
output_folder (str): The path to the folder where the texture pack will be saved. | |
""" | |
# Create the output folder if it doesn't exist | |
if not os.path.exists(output_folder): | |
os.makedirs(output_folder) | |
# Create the texture pack folder | |
pack_folder = os.path.join(output_folder, pack_name) | |
if not os.path.exists(pack_folder): | |
os.makedirs(pack_folder) | |
# Copy the images to the texture pack folder | |
for filename in os.listdir(image_folder): | |
if filename.endswith(".png"): | |
src_path = os.path.join(image_folder, filename) | |
dst_path = os.path.join(pack_folder, filename) | |
shutil.copy(src_path, dst_path) | |
# Create the pack.mcmeta file | |
with open(os.path.join(pack_folder, "pack.mcmeta"), "w") as f: | |
f.write(f'{{ | |
"pack": {{ | |
"pack_format": 6, | |
"description": "{pack_name}" | |
}} | |
}}') | |
print(f"Texture pack '{pack_name}' created successfully!") | |
# Example usage | |
create_texture_pack("My Awesome Texture Pack", "path/to/images", "path/to/output") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment