What are some common pitfalls when trying to generate text on an image in PHP?

One common pitfall when trying to generate text on an image in PHP is not setting the correct content type header before outputting the image. This can result in the text being displayed as gibberish on the image. To solve this issue, make sure to set the correct content type header to "image/png" before outputting the image.

header('Content-Type: image/png');

// Generate text on image code goes here