|
|
@@ -34,7 +34,7 @@ function imgcode($nums, $width, $high)
|
|
|
|
|
|
//建立圖示,設置寬度及高度與顏色等等條件
|
|
|
$image = imagecreate($width, $high);
|
|
|
- $black = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
|
|
|
+ $color = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
|
|
|
$border_color = imagecolorallocate($image, 21, 106, 235);
|
|
|
$background_color = imagecolorallocate($image, 235, 236, 237);
|
|
|
|
|
|
@@ -45,15 +45,19 @@ function imgcode($nums, $width, $high)
|
|
|
imagerectangle($image, 0, 0, $width - 1, $high - 1, $border_color);
|
|
|
|
|
|
//在圖示布上隨機產生大量躁點
|
|
|
- for ($i = 0; $i < 80; $i++) {
|
|
|
- imagesetpixel($image, rand(0, $width), rand(0, $high), $black);
|
|
|
- }
|
|
|
-
|
|
|
- $strx = rand(3, 8);
|
|
|
+
|
|
|
+ $font = 'Jersey_M54.ttf';
|
|
|
+ $strx = rand(2, 6); //rand(12, 27)
|
|
|
for ($i = 0; $i < $nums; $i++) {
|
|
|
- $strpos = rand(1, 6);
|
|
|
- imagestring($image, 5, $strx, $strpos, substr($code, $i, 1), $black);
|
|
|
- $strx += rand(10, 30);
|
|
|
+ $color = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
|
|
|
+ $strpos = rand(23, 29);
|
|
|
+ $strang = rand(-10, 10);
|
|
|
+ //imagestring($image, 5, $strx, $strpos, substr($code, $i, 1), $black);
|
|
|
+ imagettftext($image, 20, $strang, $strx, $strpos, $color, $font, substr($code, $i, 1));
|
|
|
+ $strx += rand(13, 25);
|
|
|
+ }
|
|
|
+ for ($i = 0; $i < 80; $i++) {
|
|
|
+ imagesetpixel($image, rand(0, $width), rand(0, $high), $color);
|
|
|
}
|
|
|
|
|
|
imagepng($image);
|