The ImagesetPixel PHP Function
PHP offers a lot of tools to work with images and graphics. One of the most popular is called the GD library and is included with most PHP installations. It lets you dynamically create and edit GIF, JPEG and PNG files, but also does a lot more.
For example, you can set the colours ("colors" if you use a different variant of English) in an image, draw text and lines on it, or even embed your own PHP code into it to run it when the file is downloaded. All of this is made possible thanks to the GD library and its various functions.
One such function is imagesetpixel(), an inbuilt PHP function that draws a single pixel at the listed coordinates. It takes four parameters: $image, $x, $y and $color.
The first two are the x and y coordinates of the location where the pixel will be drawn (in pixels). The last parameter is the colour of the pixel, which must be an identifier that was created with the help of another GD function, such as imagecolorallocate().
The GD library supports a number of different formats for its images, and we can find out which ones are supported by running the imagetypes() function. This function returns a bit-field that corresponds to the image formats supported by the version of GD linked into PHP. It will return values such as IMG_BMP, IMG_JPG, IMG_PNG, IMG_WBMP, IMG_XPM and IMG_WEBP, among others.