Replace the sequence header ("Content-type: image / gif"); imagegif ($im); by the more flexible sequence:
The following code snippet allows you to write more portable PHP applications by auto-detecting the type of GD support which is available. Replace the sequence Header("Content-type: image/gif"); ImageGIF($im); by the more flexible sequence: