- header: documentation ( source)
<?php
$sampleImage = imagecreatefrompng("http://www.w3resource-practice.com/php/sample-image.png");
$black = imagecolorallocate( $sampleImage, 0, 0, 0 );
$width = imagesx($sampleImage);
$height = imagesy($sampleImage);
imagerectangle( $sampleImage, 0, 0, $width-1, $height-1, $black );
header( "Content-type: image/png");
imagepng($sampleImage);
imagedestroy($sampleImage);