GD Library

Is there anyone out there familiar with using the GD library?

In conjunction with glReadPixels() in order to render a scene to either a .png or .jpeg.

I’m working on a Linux based program that I want to be able to render scenes to image files. This seems to be the best library to use but I can’t find any examples of how to use the info from glReadPixels() to create an image.