Yes, it's possible to convert .skel binary files to .json format programmatically! Here are your options:
Using Spine Editor (Command Line)
The Spine Editor can be run from the command line to perform batch conversions. You can use the --input and --output flags to convert multiple files:
Spine.exe --input "path/to/input/folder" --output "path/to/output/folder" --export json
This will process all .skel files in the input folder and export them as .json files to the output folder.
Using Python with spine-python Runtime
You can write a Python script using the spine-python runtime to load binary files and save them as JSON:
import os
from spine_python import SkeletonBinary, SkeletonJson, Atlas
def convert_skel_to_json(atlas_path, skel_path, output_json_path):
# Load the atlas
atlas = Atlas(file=atlas_path)
# Load binary skeleton data
skeleton_binary = SkeletonBinary(atlas)
skeleton_data = skeleton_binary.readSkeletonDataFile(skel_path)
# Save as JSON
skeleton_json = SkeletonJson(atlas)
skeleton_json.writeSkeletonData(skeleton_data, output_json_path)
# Batch conversion
input_folder = "path/to/skel/files"
output_folder = "path/to/output"
atlas_file = "path/to/your.atlas"
for filename in os.listdir(input_folder):
if filename.endswith(".skel"):
skel_path = os.path.join(input_folder, filename)
json_filename = filename.replace(".skel", ".json")
output_path = os.path.join(output_folder, json_filename)
convert_skel_to_json(atlas_file, skel_path, output_path)
print(f"Converted {filename} to {json_filename}")
Important Notes:
- Make sure you're using Spine Editor version 3.4 or the spine-python runtime version that matches 3.4
- You'll need the corresponding
.atlas file for the conversion to work properly
- The command line approach with Spine Editor is generally the most straightforward for batch conversions
The Spine Editor command line method is recommended as it's officially supported and handles all the complexity for you.