From 7fa39e90d3fa5a763a15f2539b2c04ac99efe98f Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 13 Sep 2017 17:24:07 +0200 Subject: [PATCH] minmod --- build/service/CalendarExtractor.php | 65 ++++++++++++++++++----------- 1 file changed, 40 insertions(+), 25 deletions(-) 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(); + + + + } }