The general syntax of the pfbatch command is the following:
pfbatch input_file [preset_1]...[preset_n] output_file
and can be used to perform different kind of tasks:
- export an existing PFI file to TIFF or JPeg, optionally applying additional presets (I'll come back to that later in this post)
- load a TIFF or JPeg file and save it as PFI file
- load a TIFF or JPeg file, apply some presets and export again as TIFF or JPeg
- load a PFI file, append some presets and save again as PFI
To make a concrete example, let's assume you have a certain number of edited images (saved as PFI files), and you want to create down-scaled versions to be posted on the web. You probably also want the web images to be converted to sRGB, just to make sure that they will display at least decently even on browsers that ignore ICC profiles.
The downscaling and sRGB conversions are additional operations that are not contained in the input PFI files, and that have to be applied to each image we are converting. All we need to do is to create a couple of presets for that, and then append them to the input file when calling pfbatch.
In order to create the presets, you first need to open an existing image with photoflow, and then add any layer that you want to save as a preset.
The example below shows how to add a "Scale & rotate" layer to an existing image: we will use this tool to create a preset that scales the image to a size of 800x600 pixels at most (the "Scale & rotate" tool is found under the "geom" tab of the "new layer" dialog).
Now we have to adjust the parameters of the scale tool so that the final image will fit into 800x600 pixels. The scale tool in PhotoFlow works similar to the "-resize" command in ImageMagick: when scaling the image, the tool will preserve its aspect ratio and will make sure that the resulting image fits into the given size. Therefore, we simply need to specify the desired size (in pixels) in the correspoding tool dialog:
At this point, with the "resize" layer still selected, click on the "Save" button below the layers list to save it as a preset (with extension ".pfp"):
In the following I will assume that you have saved this preset as "$HOME/presets/web_resize.pfp".
Now you have to do the same for the sRGB conversion: add one more layer of type "Color profile conversion" (you will find it in the "conv" tab of the "new layer" dialog) and leave the parameters to their defaults. In my case, the layer is simply named "sRGB":
Make sure that only the "sRGB" layer is selected, then click on the "Save" button below the layers list to save it as an additional preset (I'll assume you have called it "$HOME/presets/sRGB.pfp").
You can also save several layers in one single preset, either by selecting them before clicking on the "Save" button, or by inserting them into a group layer and saving the group itself as a preset.
At this point, everything is ready to batch-convert your first image for the web (of course you need to replace the input and output file names with your actual files):
pfbatch input.pfi $HOME/presets/web_resize.pfp $HOME/presets/sRGB.pfp output_4web.jpg
This command can also be used inside a Makefile. Here is how a generic rule could look like:
pfbatch $< $HOME/presets/web_resize.pfp $HOME/presets/sRGB.pfp $@
This will run through all the *.pfi files in the current directory and save the resulting resized JPeg files in the "Web" subdirectory.
For the future I am planning to make the batch processing tool more intuitive and user-friendly, and add some GUI interface to it. However, the pfbatch commmand will most likely remain there as the basic building block for everything else...