The // copy to jpg is only used for debugging purposes.
Try debugging counter.php by forcing an error 'echo 123/$asdf;`
A black image appears on the screen with the following text:
The image ... cannot be displayed because it contains errors.
With Debug enabled, notice the difference which is far more helpful in finding errors:
Notice: Undefined variable: x in /home/john/www/?????/counter.php on line 5
Warning: Division by zero in /home/john/www/?????/counter.php on line 5
The list of error links was for information to find how the PHP errors affects web-pages.