Previous Up Next


Sequence File (Script-Fu Script)
(Script-Fu script)

Last modified: 2000-07-03

Requires: nothing special (please, don't ask me where you can get them :))
Placement: <Toolbox>/Xtns/Script-Fu/Utils/Load Sequence,
<Image>/File/Save Sequence

File Sequence script is a piece of code which simplifies tedious task of loading dozens of images to Gimp and eventually combining them into one multi-layer image, or saving all layers in image to different files. I have originally developed it to ease the work with POV-Ray rendered animated scenes, but it can be used for any numbered images.

When POV-Ray renders a dynamic scene, it creates a sequence of numbered images, e.g. room001.tga, room002.tga, ... room150.tga. To load these images into Gimp with sequence-file script, it is sufficient to specify a template for names of files to load and numbers of first and last frame. If the images should be combined into one image, the template for layer names has to be specified too.

Similarly, when saving all layers in an image to distinctive files, it is needed to specify template for file names, number of first and last layer (Layers are counted from bottom to top, 1 being the first. If 0 is specified as a last frame, all remaining frames are saved), whether original image size is preserved (not working yet) and whether layer backgrounds are preserved.

Unfortunately, the rather annoying restriction is that GIMP must be able to deduce image file format --- usually from filename extension --- so it means that files named e.g. file.001, file.002, ... will probably pose a problem.

The importance of this script is smaller in 1.1 versions of GIMP, as the GIMP can load multiple images at once now (shift/ctrl + click in file list). However, combining into single image, etc remain useful still.

Load Dialog

Dialog example

  • File Name Template: Determines the names of files to be loaded. Below is an explanation of how this templates are expanded.
  • Layer Name Template: Specifies how to name the layers. The expansion is described below.
  • First Frame: This is the number of the first image loaded. It does not have to be the number in the first file name, as it could be overridden in File Name Template.
  • Last Frame: This is the number of the last image loaded. It does not have to be the number in the last file name, as it could be overridden in File Name Template.
  • Make One Image: If this is checked, all loaded images will be combined into layers in one image. In the opposite case, each file will be loaded into its own image.

Save Dialog

Dialog example

  • File Name Template: Determines the names of files the layers will be saved into. The expansion is explaineded below.
  • First Frame: This is the number of the first layer saved. It does not necessarily have to be the number in the first file name, as it could be overridden in File Name Template. Layers are counted from bottom to top, starting with 1.
  • Last Frame: This is the number of the last layer saved. It does not necessarily have to be the number in the last file name, as it could be overridden in File Name Template. If 0 is used, it is equivalent with number of the last layer.
  • Preserve Background: If this is checked, transparent layers are saved with transparency preserved. If it's unchecked, transparency is replaced with current background color.

The template is specified as a string, which must contain one or more consecutive characters '%' (percent sign), or one or more consecutive digits (if no '%' is present). The first occurrence is replaced during the loading or saving with an actual frame number. If '%'s are replaced, numbering starts with specified First Frame number; otherwise it starts with the replaced number. It is therefore easy to have files numbered starting with, say 52, and the resulting layers to be numbered starting from 1 and vice versa.

If the replacement is shorter than the number of consecutive '%'s (or digits), it is left-padded with zeros.

Some examples:

  First Frame  = 1
  "pict59.tga" ==> "pict59.tga", "pict60.tga", ...
  "pict%%.tga" ==> "pict01.tga", "pict02.tga", ...
  "Layer %"    ==> "Layer 1", "Layer 2", ..., "Layer 10", ...
  "Image 2/%"  ==> "Image 2/1", "Image 2/2", ...

Note: When combining images, only the first layer from each image is used, the rest is forgotten.

Note: This version is compatible with GIMP 1.1.22

Grab the source code for Gimp 1.0
Grab the source code for Gimp 1.1


Previous Up Next