• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Create blank transparent PNG images using PHP GD functions

Here is a function to create blank transparent png image for background. This function uses alpha channel information for image transparency (thus available only for PNG).  It takes width and height as a parameters and returns GD image resource:

function create_blank($width, $height){
    //create image with specified sizes
    $image = imagecreatetruecolor($width, $height);
    //saving all full alpha channel information
    imagesavealpha($image, true);
    //setting completely transparent color
    $transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
    //filling created image with transparent color
    imagefill($image, 0, 0, $transparent);
    return $image;

You may also be interested in:

Powered by

blog comments powered by Disqus