summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--captcha.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/captcha.c b/captcha.c
index 18f7d99..2b86e2e 100644
--- a/captcha.c
+++ b/captcha.c
@@ -7,10 +7,10 @@ int captcha_print(char* text)
7 gdImagePtr im = gdImageCreateFromPngPtr(file->size, file->data); 7 gdImagePtr im = gdImageCreateFromPngPtr(file->size, file->data);
8 gdImageColorTransparent(im, gdImageColorAllocate(im, 255, 255, 255)); 8 gdImageColorTransparent(im, gdImageColorAllocate(im, 255, 255, 255));
9 9
10 char text_width = strlen(text); 10 char text_width = strlen(text);
11 float letter_width = ((float) gdImageSX(im) / 26.00); 11 float letter_width = ((float) gdImageSX(im) / 26.00);
12 12
13 int image_width = letter_width * text_width; 13 int image_width = letter_width * (text_width - 2);
14 int image_height = gdImageSY(im); 14 int image_height = gdImageSY(im);
15 15
16 gdImagePtr image = gdImageCreateTrueColor(image_width, image_height); 16 gdImagePtr image = gdImageCreateTrueColor(image_width, image_height);
@@ -26,7 +26,7 @@ int captcha_print(char* text)
26 } 26 }
27 27
28 int pos; 28 int pos;
29 for(pos=0; text[pos]!='\0'; pos++) 29 for(pos=0; pos<text_width-1; pos++)
30 { 30 {
31 //printf("[pos:%d] %d\n", pos, (text[pos] - 65) ); 31 //printf("[pos:%d] %d\n", pos, (text[pos] - 65) );
32 gdImageCopyMerge(image, im, 32 gdImageCopyMerge(image, im,
@@ -35,7 +35,7 @@ int captcha_print(char* text)
35 letter_width, gdImageSY(image), 50); 35 letter_width, gdImageSY(image), 50);
36 } 36 }
37 37
38 puts("content-type: image/jpeg\n"); 38 //puts("content-type: image/jpeg\n");
39 gdImageJpeg(image, stdout, 80); 39 gdImageJpeg(image, stdout, 80);
40 40
41 gdImageDestroy(image); 41 gdImageDestroy(image);
..