Search code examples
phpz-indexgd

"z-index" in php GD


In css, we have a property called "z-index", what is the same in PHP GD and Image Functions to control the "z-index"?

I've been searching but I can't find one, please help. Thankyou


Solution

  • there nothing existing like z-index in php GD library but there several ways to overlap image over image or text over image

    $redimg = imagecreatetruecolor(100, 100);
    $image = imagecreatefrompng('image.png');
    
    // sets background to red
    $red = imagecolorallocate($redimg, 255, 0, 0);
    imagefill($redimg, 0, 0, $red);
    
    // Merge the red image onto the PNG image
    imagecopymerge($image, $redimg, 0, 0, 0, 0, 100, 100, 75);
    
    header('Content-type: image/png');
    imagepng($image);
    imagedestroy($image);
    imagedestroy($redimg);
    

    here one example, or let me know, what exactly you trying to do, I will help you There's more information here.