Chaotica Fractals Forum

command line options
Page 1 of 1

Author:  dkettle [ Fri May 07, 2021 6:47 pm ]
Post subject:  command line options

Does anyone know if there are any (possibly undocumented) command line options besides the option to load a '.chaos' file on startup? What I want to do is generate a bunch of images in various resolutions (to use as screen wallpaper) from a collection of "worlds". The only way I can see to do this is to load each world, change the resolution and save the image, one by one, which would be very labour-intensive. If it's possible to run Chaotica from the command line with parameters to do what I want, I could write a script in Python to go through all the '.chaos' files in a directory, load each one, set the resolution and save the image.

Author:  Nick [ Wed May 12, 2021 3:38 pm ]
Post subject:  Re: command line options

Current options are
silent mode doesn't display the window.
sets image output path
enables batch mode (render sequence of worlds)
sets halting sampling level.

Your best bet would be something with batch mode I think.

Author:  dkettle [ Fri May 14, 2021 12:00 pm ]
Post subject:  Re: command line options

Nick wrote:
Current options are
silent mode doesn't display the window.
sets image output path
enables batch mode (render sequence of worlds)
sets halting sampling level.

Your best bet would be something with batch mode I think.

Thanks. I'll try batch mode. That would help anyway, I'd only have to invoke it once for each desired resolution. If it exits automatically when finished, I could write a shell script or a script in Python to invoke it for each resolution.

Is there some documentation somewhere on these options? I couldn't find any mention of command line options, except to load the initial worlds.

Author:  dkettle [ Fri May 14, 2021 7:02 pm ]
Post subject:  Re: command line options

Well, it almost does what I want, but there are still a couple of problems. Here's the command I used:

> .\chaotica.exe  -batch -haltsl 8 Screen27.chaos

I expected the output file would have the same name as the input file, except for the extension of course. If I click on "Save image" in the File menu, it does (ie, Screen27.png). But when I ran it from the command line, the output file name was "pulse, lazyTravis, handkerchief, projective.png". Looking at the XML in the input file, it seems to using the value of the IFS names to generate the file name.

<?xml version="1.0" encoding="utf-8"?>
<world name="World">
   <int name="format_version">2</int>
[b]   <IFS name="pulse, lazyTravis, handkerchief, projective">[/b]
      <imaging name="Imaging">
         <int name="image_width">1024</int>
         <int name="image_height">1024</int>
         <int name="image_aa_level">2</int>
         <int name="image_layers">1</int>
         <string name="antialiasing_mode">strong</string>
         <real name="brightness">4</real>
         <vec4 name="background_colour">0.1 0.1 0.1 1</vec4>
         <bool name="apply_bg_before_curves">false</bool>

Another problem is that I expected the Chaotica app to close after it had finished the render/save process if invoked from the command line, but it stays open. Ordinarily, this wouldn't be a problem, but I might be invoking Chaotica from a script dozens of times, so I will end up with dozens of Chaotica windows open that I will have to close manually.

If I can figure out how to solve these two issues, I can write a script in Python to modify the XML and invoke Chaotica in a loop, changing the value of "image_height" and "image_width" each time through the loop to generate png files with different, commonly-used, screen resolutions. If I can get this to work, I'd be happy to post the script in a Github repository for anyone interested. Of course, you'd have to install Python to used it.

One other thing I don't understand, but it's not really a problem. When I ran it with the "-silent" option, nothing seemed to happen. No error message was displayed, but no output was produced either.

Author:  Pugnacious [ Tue May 18, 2021 1:39 pm ]
Post subject:  Re: command line options

when batch rendering, the world name is automatically assigned instead of the file name. you have to right click in the world browser and choose to rename it, and then save the file.

Automatically closing the application is something that I've suggested already. Not sure if they will add it though.

Author:  dkettle [ Tue May 18, 2021 5:55 pm ]
Post subject:  Re: command line options

Update: I've figured out how to change the resolution and the name of the output image file by modifying the XML in the '.chaos' file. Of course I understand that the format of the XML might change in a future release of Chaotica, but I'll take that chance. The only thing standing in the way of full automation (letting it run unattended) is the fact that the app doesn't close when the batch is finished, so I have to monitor it as it runs and close each Chaoatica window when the rendering is done. Maybe they'll consider adding another command-line option to do this, or modify the behaviour of the '-batch' option to close automatically.

Also, I still haven't figured out what the 'silent' option is supposed to do, as it doesn't seem to do anything at the moment. Is it broken?

For anyone interested in trying to script Chaotica using Python, here's the code. The script will search for files matching the pattern specified on the command line (you can use wildcards '?' and '*' in the file name) and for each world file it finds, render it in each of the resolutions specified in the table (see code listing below). You can add more resolutions by editing the table. If you're not running under Windows, or you installed Chaotica in some directory other than the default, you'll also have to change the line with ''.

# -*- coding: utf-8 -*-
Created on Sat May 15 08:40:41 2021

@author: David Kettle

import sys, os, subprocess, glob
import xml.etree.ElementTree as ET

def render (file, width, height):
    name = os.path.basename(file).split('.')[0]
    ext = os.path.basename(file).split('.')[1]
    path = os.path.dirname(file)
    sep = os.sep
    base = name + "-" + str(width) + 'X' + str(height)
    ifile = path + sep + name + "-" + \
        str(width) + 'X' + str(height) + "." + ext
    tree = ET.parse(file)
    root = tree.getroot()

    for ifs in root.findall('IFS'):
        for image in ifs.findall('imaging'):
            for elem in image.findall('int'):
                name = elem.attrib.get('name')
                if name == 'image_width':
                    elem.text = str(width)
                if name == 'image_height':
                    elem.text = str(height)

# if not running under Windows, update the following line:['C:\Program Files\Chaotica\chaotica.exe',

if __name__ == "__main__":

# To add (or remove) resolutions, edit this table:
    resolutions = [
        # Retina Macbook Pro (16:10 aspect ratio)
        [ 2560, 1600 ],     # Macbook Pro 13"
        [ 2880, 1800 ],     # Macbook Pro 15"
        # Windows, video (16:9 aspect ratio)
        [ 1280, 720 ],      # WXGA
        [ 1920, 1080 ],     # FHD
        [ 3840, 2160 ]      # 4K UHD

    if len(sys.argv) < 2:
        sys.stderr.write("No input files specified.\n")
    for arg in sys.argv[1:]:
        for file in glob.glob(arg):
            for reso in resolutions:
                print("Rendering "+file+" @ "+str(reso[0])+"X"+str(reso[1]))
                except Exception:
                    sys.stderr.write("Not found or invalid: "+file+"\n")

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group