Skip to content

Instantly share code, notes, and snippets.

@sabbir268
Created December 23, 2020 10:12
Show Gist options
  • Save sabbir268/f2f0fbf08625194f81f1e5148801c8c5 to your computer and use it in GitHub Desktop.
Save sabbir268/f2f0fbf08625194f81f1e5148801c8c5 to your computer and use it in GitHub Desktop.
<?php
$text = "NAVID";
$image = imagecreatefrompng('image.png');
$textColor = imagecolorallocate($image, 255, 255, 254);
$white = imagecolorallocate($image, 255, 255, 255);
$col_transparent = imagecolorallocatealpha($image, 255, 255, 255, 127);
imagefill($image, 0, 0, $col_transparent);
imagecolortransparent($image, $col_transparent);
//Full Font-File Path
$fontPath = 'C:/xampp/htdocs/personal/imgae/verdana.ttf';
foreach (str_split($text) as $key => $value) {
imagettftext($image, 50, $key*10, 1020+(50*$key), 662+(50*$key), $textColor, $fontPath, $value);
}
// imagettftext($image, 50, -4, 1200, 650, $textColor, $fontPath, "HELLO");
//Set Browser Content Type
header('Content-type: image/png');
/** Download image */
// header('Content-Description: File Transfer');
// header('Content-Type: application/octet-stream');
// header('Content-Disposition: attachment; filename=image.png');
// header('Content-Transfer-Encoding: binary');
// header('Connection: Keep-Alive');
// header('Expires: 0');
// header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
// header('Pragma: public');
//Send Image To Browser
imagepng($image);
//Clear Image From Memory
imagedestroy($image);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment