Listing 11. Save any image The GIMP can load as a JPEG image with given
compression parameters.

sub monkeyiq_gimp_convert {
  my( $inputimagename, $outfilename, $qual,
      $smoothing, $comment ) = @_;

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

  $layer = getMergedLayer( $img );

  file_jpeg_save( $img, $layer,
                  $outfilename, $outfilename,
                  $qual, $smoothing, 1, 1,
                  $comment, 0, 1, 0, 1 );
  return $img;
}

register
  ...
  "*",
  [
   [PF_STRING, "inputimage",
      "Name of image to export", ""],
   [PF_STRING, "outputimage",
      "Name of image to save to", ""],
   [PF_FLOAT,  "quality",
      "0-100 quality of JPG", ""],
   [PF_FLOAT,  "smoothing",
      "0-1 smoothing", ""],
   [PF_STRING, "comment",
      "Comment for image", ""],
  ],
  \&monkeyiq_gimp_convert;

exit main();

