Introduction - Setting up a File Action
Description
In order to run the mogrify command on the bitmap, it needs to be saved to to a file on disk. To do that select the "Create Bitmap File" action from the context menu. This will create a "File Name" variable and select the "Create Bitmap File" computational module. The object that is returned refers to a file that is created in the DataTank working directory (located in the /tmp folder).
The "File Action" module assumes that the program can be run on the command line without user interaction, and will read the input file or files from the directory it is launched. The program is also assumed to write a single output file into that same directory. When you drag a file onto the "Swirl action" variable it is added to the bottom of the module. In this example, when ever the module is run, it will go through the following steps
- Creates a temporary directory, inside the DataTank working folder.
- Creates the file Picture.tiff inside the folder. This is done by using symbolic links, to avoid copying.
- Creates a small shell script with the line
"/usr/local/bin/mogrify" -swirl 200 Picture.tiff
This means that the path can have spaces, but you need to use quotations inside the argument list just as you need on the command. line. - Runs the shell script from within the temporary folder
- Moves the Picture.tiff file (the output name) into the temporary file folder.
- Deletes the temporary folder created in step 1
- Returns a file object that contains the output file. This file will have the ending .tiff, but will not be called Picture.tiff.
As is always the case, the action will not be performed until it is needed, and the output file will be saved so that it doesn't have to be rerun again if none of the argument files has changed.