wp-comment-post.php and header already sent issues

Okay, just looking through this code quickly, it looks like the problem may be that the getImgID() function is echoing rather than returning its output.

This function is called from within another function, guan_getImgID_inserter(), that is hooked into the comment_text filter hook.

Anything that filters comment_text (or any filter hook, for that matter), should be returning its output, since the hook is already echoed, usually via a call to echo apply_filters().

So, you may want to change the echo calls to return calls, in lines 176 and 178. i.e. these:

    if($imgIDNow != "") {
            $str = substr($imgIDNow, 4, strlen($imgIDNow));
            echo "<div id=\"comment-".$str."\"><a href="#".$str."">noted on #".$imgIDNow."</a></div>";
    } else {
            echo "&nbsp;"; 
    }

should instead be this:

    if($imgIDNow != "") {
            $str = substr($imgIDNow, 4, strlen($imgIDNow));
            return "<div id=\"comment-".$str."\"><a href="#".$str."">noted on #".$imgIDNow."</a></div>";
    } else {
            return "&nbsp;"; 
    }

I’m not 100% certain that’s the problem, but it’s at least worth a shot…