diff --git a/build/service/CalendarExtractor.php b/build/service/CalendarExtractor.php index a027739..22b486e 100644 --- a/build/service/CalendarExtractor.php +++ b/build/service/CalendarExtractor.php @@ -228,7 +228,7 @@ - /* (3) Exctracts an event + /* (3) Exctracts an event using OCR * * @uid Image uid * @start Start rect (x, y) @@ -236,37 +236,52 @@ * ---------------------------------------------------------*/ public function extractEvent($uid, $start=null, $stop=null){ + + $link = __ROOT__."/tmp/$uid.jpeg"; + /* [1] Get the right clip - =========================================================*/ - /* (1) Create clipped copy */ - $clip = \imagecreatetruecolor($stop[0]-$start[0], $stop[1]-$start[1]); + =========================================================*/ { + /* (1) Create clipped copy */ + $clip = \imagecreatetruecolor($stop[0]-$start[0], $stop[1]-$start[1]); - $copied = \imagecopyresized( - $clip, // destin img - $this->img_res, // source img - 0, // dest x - 0, // dest y - $start[0], // src x - $start[1], // src y - $stop[0]-$start[0], // dest w - $stop[1]-$start[1], // dest h - $stop[0]-$start[0], // src w - $stop[1]-$start[1] // src h - ); + $copied = \imagecopyresized( + $clip, // destin img + $this->img_res, // source img + 0, // dest x + 0, // dest y + $start[0], // src x + $start[1], // src y + $stop[0]-$start[0], // dest w + $stop[1]-$start[1], // dest h + $stop[0]-$start[0], // src w + $stop[1]-$start[1] // src h + ); - /* (2) Manage copy error */ - if( !$copied ) - throw new \Exception("Cannot clip image"); + /* (2) Manage copy error */ + if( !$copied ) + throw new \Exception("Cannot clip image"); - /* (3) Save to file */ - \imagesavealpha($clip, true); - if( !\imagejpeg($clip, __ROOT__."/tmp/$uid.jpeg") ) - throw new \Exception("Cannot save image"); + /* (3) Save to file */ + \imagesavealpha($clip, true); + + if( !\imagejpeg($clip, $link) ) + throw new \Exception("Cannot save image"); + + } /* [2] Process OCR - =========================================================*/ - // TODO: + =========================================================*/ { + + /* (1) Creates a Tesseract (OCR) instance */ + // $ocr = new Tesseract($link); + + /* (2) Reads from file */ + // $ocr->read(); + + + + } }