diff --git a/.gitignore b/.gitignore index d9befd7..cc88be3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -demo/out.jpg +demo/*.jpg +demo/*.pgm diff --git a/CaptchaBuilder.php b/CaptchaBuilder.php index eb3b0b6..084313c 100644 --- a/CaptchaBuilder.php +++ b/CaptchaBuilder.php @@ -203,7 +203,7 @@ public function build($width = 150, $height = 40, $font = null, $fingerprint = n // Apply effects $square = $width * $height; - $effects = $this->rand($square/5000, $square/2500); + $effects = $this->rand($square/3000, $square/1000); for ($e = 0; $e < $effects; $e++) { $function = $this->getScramblingFunction(); for ($i=0; $i<$square/5000; $i++) { diff --git a/demo/ocr.php b/demo/ocr.php new file mode 100644 index 0000000..705e37e --- /dev/null +++ b/demo/ocr.php @@ -0,0 +1,41 @@ +build() + ->save('out.jpg', 20) + ; + + shell_exec('convert out.jpg out.pgm'); + $result = trim(shell_exec('ocrad out.pgm')); + + if ($result == $captcha->getPhrase()) { + echo "passed at ocr\n"; + shell_exec("cp out.jpg passed$passed.jpg"); + $passed++; + } else { + echo "failed\n"; + } +} + +echo "\n"; +echo "Over, $passed/$tests readed with OCR\n"; diff --git a/demo/output.php b/demo/output.php index ec1a5b9..ecb8902 100644 --- a/demo/output.php +++ b/demo/output.php @@ -8,6 +8,6 @@ header('Content-type: image/jpeg'); CaptchaBuilder::create() - ->build(300, 70) + ->build() ->output(20) ;