Created
March 24, 2012 23:45
-
-
Save stefanocudini/2189163 to your computer and use it in GitHub Desktop.
image text centered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
header('Content-Type: image/png'); | |
$size= 80; | |
$extImg = imagecreatetruecolor($size,$size); | |
$targetFileImg = 'mime.png'; | |
$ext = trim($_GET['t']); | |
$ctext = imagecolorallocate($extImg, 100, 100, 100); //testo | |
$ctrasp = imagecolorallocate($extImg, 200,200,200); //sfondo | |
imagefilledrectangle($extImg,0,0,$size,$size,$ctrasp); | |
$font = 5;#imageloadfont('trebuc.ttf'); | |
$fontW = ImageFontWidth($font); | |
$fontH = ImageFontHeight($font); | |
$textW = $fontW * strlen($ext); | |
$textCenter = ceil(($size - $textW) / 2); | |
$textH = $fontH; | |
$textMiddle = ceil(($size - $textH) / 2); | |
imagestring($extImg, $font, $textCenter, $textMiddle, $ext, $ctext); | |
imagepng($extImg);//crea file thumb! | |
imagedestroy($extImg); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment