<?php
$text = 'TEXTEXT';
$h = $w = 300;
$font = 'times.ttf';
$image = imagecreatetruecolor($h,$w);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$red = ImageColorAllocate($image, 255, 0, 0);
ImageFill($image, 1, 1, $black);
imageline($image, 150, 0, 150, 300, $white);
ImageFill($image, 1, 1, $white);
for($x=1;$x<$h;$x++)
for($y=1;$y<$w;$y++)
$arr[$x][$y] = imagecolorat($image,$x,$y);
//imagestring($image, 5, 5, 150, md5(rand(1,100)), $red);
imagettftext($image, 50, rand(60,0), 100, 250, $red, $font, $text);
for($x=1;$x<$h;$x++)
for($y=1;$y<$w;$y++)
{
$arr2[$x][$y] = imagecolorat($image,$x,$y);
if($arr[$x][$y] != $arr2[$x][$y])
{
if($arr[$x][$y] == 0) imagesetpixel($image,$x,$y,$white);
else imagesetpixel($image,$x,$y,$black);
}
}
header("Content-Type: image/png");
ImagePng($image);
ImageDestroy($image);
|