Image Magick.
It's an old Linux/Unix open source program that rocks and is available for Mac. Supports many, MANY formats and will do pretty much any basic operation to an image, as well as several image processing algorithms. Even has a C library that you can use, if you're into that kind of stuff.