1
0
mirror of synced 2025-01-18 22:24:04 +01:00

Pad out written PNG frames so all of them have the same number of digits in them.

This commit is contained in:
Jennifer Taylor 2021-05-21 21:47:26 +00:00
parent 03381ee8ca
commit d031b2107a

View File

@ -2,6 +2,7 @@
import argparse
import io
import json
import math
import os
import os.path
import sys
@ -800,13 +801,18 @@ def main() -> int:
filename = args.output[:-4]
ext = args.output[-4:]
for i, img in enumerate(images):
fullname = f"{filename}-{i}{ext}"
# Figure out padding for the images.
frames = len(images)
if frames > 0:
digits = f"0{int(math.log10(frames)) + 1}"
with open(fullname, "wb") as bfp:
img.save(bfp, format=fmt)
for i, img in enumerate(images):
fullname = f"{filename}-{i:{digits}}{ext}"
print(f"Wrote animation frame to {fullname}")
with open(fullname, "wb") as bfp:
img.save(bfp, format=fmt)
print(f"Wrote animation frame to {fullname}")
elif args.action == "list":
paths = renderer.list_paths(verbose=args.verbose)