It doesn't even need to create an image on the fly.
You can just have your script to do it's stuff then at the bottom of the script do a Header("Location: /images/blank.gif"); exit();
For example
//Start code
include('../connect.php');
$sql = mysql_query($query);
Header("Location: /images/blank.gif"); exit();
//End Code
This code will then show the image in your Header tag after it has processed what it needs to do