Back to Top

Make Transparent Image With Your String Using PHP GD

Updated 27 February 2024

For this  PHP GD is required on your server 

$imageWidth=300; //width of your image
$imageHeight=200;// height of your image
$logoimg = imagecreatetruecolor($imageWidth, $imageHeight); //create Image
//for transparent background
imagealphablending($logoimg, false);
imagesavealpha($logoimg, true);
$col=imagecolorallocatealpha($logoimg,255,255,255,127);
imagefill($logoimg, 0, 0, $col);
//for transparent background
$white = imagecolorallocate($logoimg, 255, 255, 255); //for font color
$font = "advanced_pixel_lcd-7.ttf"; //font path
$text="Your Text..."; //your text which you want to show in image
$fontsize=20; // size of your font
$x=100; // x- position of your text
$y=100; // y- position of your text
$angle=0; //angle of your text 
imagettftext($logoimg, $fontsize,$angle , $x, $y, $white, $font, $text); //fill text in your image
$target="temp.png"; //path of target where you want to save image
imagepng($logoimg,$target); //save your image at new location $target

Start your headless eCommerce
now.
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home