GIMP Script-fu

Align Down
"<Image>/Layer/Align Down"
PDB Name:
sg-align-down.scm (after the page appears, click on the "Download" command)


This script will reposition the active layer so that it is center-aligned with the visible layer beneath it in the layerstack. If there is an active selection then the active layer will be centered within the boundaries of the selection. If there is no visible layer beneath the active layer (in the current layer group) then the active layer will be centered relative to the current layer group.

While GIMP offers both the Align Tool and the Align Visible Layers plug-in, these are both a bit cumbersome to use for simple centering operations. This script, in conjunction with an appropriate selection or toggling of various layers' visibility, provides simplified support for a common use case.

Since all channels have the same boundaries as the image, running Align Down on a channel wouldn't normally have any effect. Rather than do nothing -- or worse, generate an error -- the script will treat the channel as a selection and center that selection on the image. For example, if you want to center a circular selection on the image, make your selection (on a layer) and then enable Quickmask mode and perform Align Down. When you exit Quickmask the selection will be centered.

The script is also useful for the situation where you have made a selection and performed an "Edit->Copy", followed by an "Edit->Paste As->New Layer". The new layer which results is anomalously always placed in the upper-left corner of the image -- not directly above the original location (as would happen with "Edit->Paste"). Running Align Down will reposition the new layer to be above its original location (assuming the original selection is still active).

Note: the name "Align Down" is derived from the fact that the rule for determining the "target" layer is the same as that for the "Merge Down" function (i.e., the first visible layer underneath the active one). Despite the name, there is no change in layerstack positions of any of the layers.