Multi-Layer TIFF editing with the Gimp
Hugin, and its associated stitcher nona can output multi-layer TIFF files, in which all remapped images are arranged in layers with appropriate offsets. These compact TIFF files are useful for visualizing and editing alpha masks, for instance to exclude moving objects or troublesome stitch areas, prior to passing to enblend for final blending. Gimp can read, but not write these multi-layer TIFF files, and enblend cannot read them. Another compact output option is a set of Cropped TIFF files, which enblend can read. Multi-layer TIFFs are simply a collection of cropped TIFFs in a single file. tiffsplit (a TIFF Tools program) can split a multi-layer file into separate cropped TIFF images, prior to running enblend.
Unfortunately, no editors (except Cinepaint) preserve the offset information in Cropped TIFFs, which means enblend cannot use them after any editing (it will stack them all on top of each other). An option for making use of multi-layer TIFFs is available with the Gimp script save-layers-tiff (due to changes in the scripting language, use save-layers-tiff-24 for GIMP 2.4 and later). This script saves all layers, applying any layer masks, to full size (non-cropped) images, which enblend can accept. To install, simply drop the unzipped script in ~/.gimp-2.2/scripts/ (or whatever version of Gimp you are running).
On my installation starting up gimp-2.6 then complains about invalid utf-8 strings, and the script is not available. If this happens to you, there is a workaround. You will have to one-by-one set just one layer visible, and then "save-as", set a filename, and then chose "merge-visible-layers" when exporting to tiff.
The recommended workflow is then:
- Output to multi-layer TIFF using Hugin.
- Open the resulting multi-layer TIFF in the Gimp, version 2 or later.
- Edit the alpha channel by erasing undesired areas (disabling view of all but 2 layers, and reducing the opacity of the upper layer can be useful here). You can also transfer the alpha channel to a layer mask for more fine-tuned editing.
- After you are done editing masks, choose Script-Fu->Utils->Save Layers as Individual TIFFs. The files will be saved as file000.tif, etc., for an input file file.tif. Note that any layer masks will be applied (converted back into alpha channels), and the layers themselves will be expanded to the full image size.
- Run enblend, like enblend -wzo file.tif file[0-9]*.tif (omit the w for non-360's).
- (Optionally) remove the fileXXX.tif files, and save the multi-layer TIFF in a format which will preserve your edits, e.g. Gimp's native format, file.xcf. You can then safely delete the multi-layer TIFF.
Note that if no alpha mask editing is needed, it will be somewhat faster to use tiffsplit to split the multi-layer tiff into individual cropped TIFFs, and pass those to enblend.