Create PNG file : PNG « Language Basics « PHP





Create PNG file

<html>
<body>
<?php
    $img=ImageCreate(300,300);
    $bgcolor=ImageColorAllocate($img,200,200,200);
    $red=ImagecolorAllocate($img,255,0,0); 
                                                            
    Imagerectangle($img,50,50,150,150,$red);
    Imagefilledrectangle($img,50,170,150,270,$red);
                                                            
    ImagePNG($img,"pic.png");
    ImageDestroy($img);
?>
<img src="pic.png" border=0>
</body>
</html>

           
       










Related examples in the same category

1.Add an PNG image to the image you generated