in reply to Controlling The Gimp
It should be possible using modules like Gimp or Gimp::OO, but I have not used them myself and they seem very old.
Have you considered using ImageMagic or Imager for this task? Just search the CPAN...
Hope this helps