Results 1 to 1 of 1
  1. #1
    emoisback
    emoisback is offline
    Full member
    Join Date
    2011 Dec
    Location
    Indonesia there i'm
    Posts
    508
    Thanks Thanks Given 
    83
    Thanks Thanks Received 
    244
    Thanked in
    68 Posts
    Rep Power
    13

    Simple OCR ( Optical character recognition ) Breaker.

    Oke....

    Today i'll share what i have..

    this is a code to make u can read a Simple Captcha.

    this help me to post my site to make backlink and make my Page Rank in google search up.

    Here is the class code..

    Sorry for function name i used indonesian language.

    PHP Code:

    <?php
      error_reporting
    (E_ALL);

      class 
    OCRbreaker {

        function 
    read($data) { 
            
    $orig  imagecreatefromstring($data);
            
    $letter_num 2;

            
    $pos = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","w","y","z");
            
    $code '';
            
    $lbl "";
            
    $hasil = array();
            foreach (
    $pos as $p1) {
                    foreach (
    $pos as $p2) {
                            
    $lbl $p1.$p2;
                            
    $gbr $this->gambar($lbl);
                            
    $skor $this->beda($orig$gbr);
                            
    $hasil[$lbl] = $skor;
                    }
            }
            
    asort($hasil);
            foreach (
    $hasil as $k=>$v) { $kode $k; break; }
            return 
    $kode;
      }

      function 
    ketengah($image$image_width$string$font_size$y$color) { 
            
    $text_width imagefontwidth($font_size)*strlen($string); 
            
    $center ceil($image_width 2); 
            
    $x $center - (ceil($text_width/2)); 
            
    ImageString($image$font_size$x$y$string$color); 
      } 
      
      function 
    gambar($teks) { 
            
    $width 30;
            
    $height 20;

            
    $image ImageCreate($width$height);
            
    $black ImageColorAllocate($image000);
            
    $white ImageColorAllocate($image255255255);
            
    $grey ImageColorAllocate($image200200200);
            
    ImageFill($image00$white);
            
    $this->ketengah($image$width$teks33$black);
            
    ImageRectangle($image,0,0,$width-1,$height-1,$grey);
            return 
    $image;
      }
      
      function 
    gambar_canvas($teks) {
            
    $img $this->gambar($teks);
            
    header("Content-Type: image/jpeg");
            
    ImageJpeg($img);
            
    ImageDestroy($img);
      }

      function 
    beda($i1$i2) {
            
    $sx1 imagesx($i1);
            
    $sy1 imagesy($i1);

            if (
    $sx1 !== imagesx($i2) || $sy1 !== imagesy($i2)) {
                return 
    100;
            }

            
    $diffi imagecreatetruecolor($sx1$sy1);
            
    $green imagecolorallocate($diffi02550);
            
    imagefill($diffi00imagecolorallocate($diffi000));

            
    $different_pixels 0;

            for (
    $x 0$x $sx1$x++) {
                for (
    $y 0$y $sy1$y++) {

                    
    $rgb1 imagecolorat($i1$x$y);
                    
    $pix1 imagecolorsforindex($i1$rgb1);

                    
    $rgb2 imagecolorat($i2$x$y);
                    
    $pix2 imagecolorsforindex($i2$rgb2);

                    if (
    $pix1 !== $pix2) {
                        
    $different_pixels++;
                        
    imagesetpixel($diffi$x$y$green);
                    }

                }
            }

            if (!
    $different_pixels) {
                return 
    0;
            } else {
                
    $total $sx1 $sy1;
                return 
    number_format(100 $different_pixels $total2);
            }
      }
    }
    ?>
    Hope it usefull for all of you..

    if it help, please give thank
    Learn from PGC for Share on PGC..


    For another Stuff i have make try to find it [Please, register to view links]
    If i have help you, please thanks and respect ..

  2. The Following User Says Thank You to emoisback For This Useful Post:


Similar Threads

  1. [C++] How to make a simple bot
    By Dwar in forum Programming Tutorials
    Replies: 3
    Last Post: 2014-10-04, 12:53 PM
  2. [Request] Method to move character to specific cordinate
    By psycheangel in forum Aika Online
    Replies: 0
    Last Post: 2011-12-15, 02:02 AM
  3. [C++] Simple Proxy Reference
    By Dwar in forum Programming Tutorials
    Replies: 1
    Last Post: 2011-11-18, 10:52 AM
  4. [Release] Requiem Simple Launcher
    By Dwar in forum Requiem Online
    Replies: 24
    Last Post: 2011-04-30, 04:00 AM
  5. [Guide] Rift Character Creation
    By Grooguz in forum Rift Guides, Tutorials
    Replies: 0
    Last Post: 2011-03-14, 08:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •