A note to the previous question (if you still don't know it :))...
GIF's are 256 colors (or 8 bit), and the resample function needs true color I guess... that's why it works with JPG's and not with GIF's.
Next thing... you take a string, write it to file, open the file (imagecreatefromgif), and delete the file again.
if you do imagecreatefromstring($string) you can skip the temporary file part.