I'm not sure. I already have GIMP and use it for various other purposes as well, so in my case it made the most sense to use that instead of tinkering with command line stuff. That being said, you may have luck with ImageMagick, but I'm not sure if it'll work for this.