The solution does work ... and there are publishers and authors willing to charge you money to show you that it does:
PHP Graphics, Kent, Slenc, & Sweat. Published by Wrox. The code I posted is taken almost directly fom the book.
Regarding <img> tags, Take a look at the W3C specification; the href attribute is not supported for <img> tags.
And why you would want to do it this way? To paraphrase wanaka: for security reasons, the file is outside the web root. PHP will still be able to access it, though the web user without permissions will not. Additionally, with the method I posted, the graphic can be modified, watermarked, scaled, and more, all on the fly, based on user input.
And as for headers ... take a longer look at my code.