Using console mode with Chameleon

JAlbum can be controlled from the command line (known as Console Mode), and generally accepts the same parameters that you are able to set through the graphical user interface (GUI).

There is a lot of Console Mode information readily available on the JAlbum website (see , which gives the list of allowed parameters and their defaults) and JAlbum Forum (for examples, see Automatically process sub-Projects and Making a multi-skin album in one pass). Note that the command line and GUI do not exactly mirror each other, and that there are some oddities to be aware of (ie the “Ignore Pattern” is one). User-defined variables are passed as -user.yourVariable “Value”, while skin-defined variables have a -skin prefix.

The Console Mode is great for automated album generation and updates. Webmasters can even make scripts that call JAlbum regularly to update server albums etc. However, this and following tutorials are primarily aimed at conventional albums created with the Chameleon skin.

A convenient and traditional way of using Console Mode is by putting the relevant code in a batch file, a plain text file with the .bat or preferably .cmd extension (the latter runs in native mode which is faster), which is easily created using Notepad, for example. This code executes JAlbum, using the parameters set within the GUI, which are themselves then stored in the relevant project (.jap) file.

A simple batch file may just call a single, standard .jap project, and running it is the same as executing the project from within JAlbum. All the relevant information required to build the album is contained within the .jap file, ie Image and Output directories, Image Bounds etc. The only batch file code really required to process an album is therefore:

java -Xmx400M -jar "C:\Program Files\JAlbum\JAlbum.jar" -projectFile "xxx.jap" 

The key elements are:

  • java -Xmx400M
    Ref where it is stated “The -Xmx400M flag allows JAlbum to grab up to 400MB or RAM if needed. The default of 64MB is not enough”. For a further discussion on this, see Console Mode Memory Usage , suffice to say that it is recommended to use the above value.
  • -jar "C:\Program Files\JAlbum\JAlbum.jar"
    Command to run JAlbum; the full path is specified for completeness.
  • -projectFile "xxx.jap"
    Enter the relevant project filename. In this case, it assumed that the batch file exists in the same location as the associated project file, so a full path name is not required.

As no other values are specified, all the settings set in the GUI and stored in the associated .jap file are processed. One very important point; use the command line parameter “-appendImages” when you would use “Make Changes“, leave it out when you would use “Make All“.

Moving on from this simple case, and noting that generally command line parameters entered in the .bat/.cmd file take precedence over the .jap file, the full power of batch files can be explored. For instance, a single .jap project can be created and called many times, each with a few tweaks to achieve the overall, desired effect. Thus, to control the Index Page layout for example, one may use:

java -Xmx400M -jar "C:\Program Files\JAlbum\JAlbum.jar" -projectFile "xxx.jap"
java -Xmx400M -jar "C:\Program Files\JAlbum\JAlbum.jar" -projectFile "xxx.jap" -subdirs false -thumbSize 120x120 -cols 6 

Here, line 1 executes the xxx.jap project file. Line 2 then repeats the process, but this time the parameters -subdirs false -thumbSize 120x120 -cols 6 would ensure that, respectively, subdirectories are not processed, the Image Bounds/Thumbnails are set at 120×120, and the Thumbnail layout/columns is set to 6.

Again, one is pointed to, which gives the list of allowed parameters and their defaults.

It quickly becomes apparent that the possibilities are almost limitless. Some albums may have a number of project files to produce the desired, overall effect; each subfolder, for instance, may use a different sub-style of a particular skin. In this case, create a single .jap file based on the skin and its default sub-style, and use the -skin.subStyle parameter accordingly. There are many other applications which greatly benefit or are only practical by using batch files:

  • Multi-pass albums (ranging from a simple 2 nd pass to create a particular Index Page layout, as in the example above, to a complicated album which requires many passes of different skins).
  • Controlling the layout, ie different Image Bounds for different folders, as may be desired in a “Years & Months” diary type album.
  • When “Large thumbs for Folders” is selected on Chameleon/Thumbnails tab, the folder thumbnails can be set to any convenient size, independent of the general Image Bounds (see Large Folder Thumbnails ), and a batch file makes life easier.
  • Programmatically created Hidden or Private Folders (see Hidden or Private Folders).
  • Updating complicated albums can be rather time consuming, but with a suitable batch file, an update is only a single-click away.

Other Console Mode/batch file advantages that are less obvious include:

  • Helps de-bugging
    The Console Mode actually shows each file being processed. Problem files are identified individually, and it can also be helpful in optimisation, as repeat builds are clearly visible.
  • Fine-tuning during album creation
    With complicated albums, one might want to work on a specific part in isolation. Simply use the relevant code only in a test batch file (or REM out the unnecessary code). This is especially useful if the part in question also requires another .jap file to be to be built first; quick edits can be made and all the items processed with a single click.
  • Cater for changing Chameleon versions
    The Chameleon skin is very much a live project, and is updated often. It is time consuming to check many, many project files to ensure that the latest settings are being used, etc. Thus, having a single .jap file, which may be called many times within a single batch file, means that a minimal number of .jap files need to be re-checked when Chameleon is updated.

Project files are not simply transferable from one location to another, in that the Image and Output directories are effectively hard-coded in. So at home a drive is “D”, at work it’s “K”. Keep 2 copies of a batch files (a simple edit/replace changes the drive letter in one go) and run the appropriate batch file for the relevant drive.

Leave a Reply