A word of warning when outputting images to the browser...
Make sure there is no extra spaces around the <?php ?> tags, in the file you are editing, and also any included files.
I began to think there was a bug in GD or something, and I checked the file I was working on, but forgot about the includes...
Hours gone..