See fopen() for more details on how to specify the filename and Appendix I for a list of supported URL protocols.
ImageCreateFromPNG() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error PNG: