>>71083updated your code a bit, now it allows you to tinker with the settings using argparse.
i also fixed openssl giving an error saying it needed either "-pbkdf" or "-iter", so i just passed "-iter 1"
python
from tempfile import TemporaryDirectory
import argparse
import subprocess
import re
from random import randbytes
from os import system, chdir, getcwd, urandom
from os.path import join
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--iterations", help="Amount of iterations", default=100, type=int)
parser.add_argument("-d", "--depth", help="Image depth", default=32, type=int)
parser.add_argument("-f", "--framerate", help="Final gif framerate", default=15, type=int)
parser.add_argument("-o", "--output", help="Output file", default="out.gif", type=str)
parser.add_argument("-c", "--cipher", help="Cipher to use", default="aes-128-ecb", type=str)
parser.add_argument("--key-size", help="Amount of bytes for the encryption key, doesn't really matter", default=8, type=int)
parser.add_argument("--hwgen", help="Use hardware rng instead of python's builtin rng", action="store_true", default=False)
parser.add_argument("file", help="File to convert", type=str)
args = parser.parse_args()
cwd = getcwd()
def main():
res = subprocess.check_output(
f"identify '{args.file}'",
shell=True, text=True
)
size = re.search(r"(\d+x\d+)", res)
if not size:
raise Exception("Could not get image size")
size = size.groups()[0]
with TemporaryDirectory() as tempdirpath:
temprgba = join(tempdirpath, "photo.rgba")
system(f"convert -depth {args.depth} '{args.file}' {temprgba}")
for iteration in range(1, args.iterations):
tempenc = join(tempdirpath, f"photo_{iteration}.rgba")
tempout = join(tempdirpath, f"{iteration}.png")
r = urandom(args.key_size) if args.hwgen else randbytes(args.key_size)
system(f"openssl enc -{args.cipher} -e -in {temprgba} -out {tempenc} -k {r.hex()} -iter 1")
system(f"convert -size {size} -depth {args.depth} {tempenc} {tempout}")
chdir(tempdirpath)
system(f"ffmpeg -f image2 -framerate {args.framerate} -i %d.png {join(cwd, args.output)}")
chdir(cwd)
if __name__ == "__main__":
main()