PHP is not limited to creating just HTML output. you can create image files using PHP. It just needs to install GD libraray to create variety of image formats like GIF, PNG, JPEG, WBMP, and XPM. PHP output image streams directly to a browser. You will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
To read more about this article Click Here