$param = $_GET['id']; // remember to sanitize that - it is user input!
// we need to be sure ours script does not output anything!!!
// otherwise it will break up PNG binary!
// here DB request or some processing
$codeText = 'DEMO - '.$param;
// end of processing here
$debugLog = ob_get_contents();
// outputs image directly into browser, as PNG stream