Or ... you can go and compile the beta 2.0 version of GDlib, which comes with a leetish jpeg, png and bmp support. however ... the Gif format is traded out and not supported at all.
I've been using 2.0 for quite a while, only bug I've noticed is an alpha channel bug when merging a PNG image with a JPEG image (to stick a logo on the image ...).