It is currently Sun Oct 24, 2021 7:16 pm


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: command line options
PostPosted: Fri May 07, 2021 6:47 pm 

Joined: Fri May 07, 2021 6:44 pm
Posts: 6
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.


Top
Offline Profile  
 
 Post subject: Re: command line options
PostPosted: Wed May 12, 2021 3:38 pm 

Joined: Mon Jun 19, 2017 1:51 pm
Posts: 191
Current options are
-silent
silent mode doesn't display the window.
-o
sets image output path
-batch
enables batch mode (render sequence of worlds)
-haltsl
sets halting sampling level.

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


Top
Offline Profile  
 
 Post subject: Re: command line options
PostPosted: Fri May 14, 2021 12:00 pm 

Joined: Fri May 07, 2021 6:44 pm
Posts: 6
Nick wrote:
Current options are
-silent
silent mode doesn't display the window.
-o
sets image output path
-batch
enables batch mode (render sequence of worlds)
-haltsl
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.


Top
Offline Profile  
 
 Post subject: Re: command line options
PostPosted: Fri May 14, 2021 7:02 pm 

Joined: Fri May 07, 2021 6:44 pm
Posts: 6
Well, it almost does what I want, but there are still a couple of problems. Here's the command I used:

Code:
> .\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.

Code:
<?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.


Top
Offline Profile  
 
 Post subject: Re: command line options
PostPosted: Tue May 18, 2021 1:39 pm 

Joined: Tue Jul 28, 2020 12:38 am
Posts: 52
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.


Top
Offline Profile  
 
 Post subject: Re: command line options
PostPosted: Tue May 18, 2021 5:55 pm 

Joined: Fri May 07, 2021 6:44 pm
Posts: 6
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 'subprocess.call()'.

Code:
# -*- 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'):
        ifs.set('name',base)
        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)

    tree.write(ifile,encoding='utf-8',xml_declaration=True)
   
# if not running under Windows, update the following line:
    subprocess.call(['C:\Program Files\Chaotica\chaotica.exe',
                      '-o',path,
                      '-batch',
                      '-haltsl','8',
                      ifile],
        shell=True)
   
    os.remove(ifile)

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")
        sys.exit
   
    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]))
                try:
                    render(file,reso[0],reso[1])
                except Exception:
                    sys.stderr.write("Not found or invalid: "+file+"\n")
                    sys.exit


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Theme created StylerBB.net