in reply to How to save an image (using GD) to a file
You are opening for reading, not writing here. This may be your problem. I am assuming you have an older version of GD, since the newer ones don't support GIFs.
Cheers, KM