It is often necessary to combine several layers into one. This is particularly useful prior to saving an image to a non-GIMP format such as JPEG or GIF. There are two ways of combining layers in the GIMP. The method to use depends on the final use of the resulting image.
It is possible to merge a subset of layers from an image into a single layer. This is accomplished by choosing Merge Visible Layers from the Layers menu or by simply typing C-m in the image window. Alternatively, it is sometimes convenient to merge just two adjacent layers in the layer stack. This can be done with Merge Down, found in the Layers menu. The use of this function merges the active layer with the next visible layer down in the stack. Merge Down can be conveniently invoked by typing C-S-m in the Layers dialog. A nice use of Merge Down is illustrated in Section 9.1.4.
The function Flatten Image, found in the Layers menu, is an alternative to Merge Visible Layers. This function merges all the layers regardless of their visibility in the image window. In addition, Flatten Image applies all the layer masks to their respective layers (for more on layer masks, see Section 4.2) and deletes any remaining alpha values in the image. In fact, Flatten Image is the only function in the GIMP that can remove the alpha channel from an image. Channel masks, however, are neither applied nor deleted (see Section 4.1 for more on channel masks). Typically an image is flattened in order to save it in an image format that does not support layers or transparency. The JPEG format is an example of this.