Listing 7. Make all layers hidden in the output image.

#
# Hide all layers
#
sub Layers_hideAll {
  my( $img ) = @_;

  @layers = Gimp->image_get_layers( $img );
  foreach $l (@layers) {
    Gimp->layer_set_visible( $l, 0 );
  }
}
...
sub monkeyiq_gimp_layers_hideall {
  my($inputimagename,$outfilename) = @_;

  $img = gimp_file_load( $inputimagename,
                         $inputimagename );
  Layers_hideAll( $img );

  gimp_xcf_save( 0, $img, 0,
              $outfilename, $outfilename );
  gimp_image_delete( $img );
}