diff --git a/build/router/controller/ics.php b/build/router/controller/ics.php index aa326fb..2f0e188 100644 --- a/build/router/controller/ics.php +++ b/build/router/controller/ics.php @@ -39,11 +39,13 @@ /* [2] Display file =========================================================*/ /* (1) Headers */ - header('Content-Type: text/calendar; charset=utf-8'); - header('Content-Disposition: attachment; filename='.$this->diplome_id.'.ics'); + // header('Content-Type: text/calendar; charset=utf-8'); + // header('Content-Disposition: attachment; filename='.$this->diplome_id.'.ics'); /* (2) Body */ + echo "
"; readfile($file_name); + echo ""; } diff --git a/build/service/CalendarExtractor.php b/build/service/CalendarExtractor.php index 399246c..44c9fe2 100644 --- a/build/service/CalendarExtractor.php +++ b/build/service/CalendarExtractor.php @@ -3,6 +3,7 @@ namespace service; use \lightdb\core\lightdb; + use \service\Tesseract; class CalendarExtractor{ @@ -197,7 +198,9 @@ $this->event[$uid][$time] = [ $this->yToTime($day_n, $y) ]; // {6} Exctract event's image // - $this->event[$uid][$time][1] = $this->extractEvent("$time-$uid", [$col_x, $start_y+1], [$col_ind[$day_n+1]-1, $y]); + $ev = $this->extractEvent("$time-$uid", [$col_x, $start_y+1], [$col_ind[$day_n+1]-1, $y]); + $this->event[$uid][$time][1] = $ev[0]; + $this->event[$uid][$time][2] = $ev[1]; } @@ -240,42 +243,72 @@ $link = __ROOT__."/tmp/$uid.jpeg"; $width = $stop[0]-$start[0]; $height = $stop[1]-$start[1]; + $resize_factor = 2; /* [1] Get the right clip =========================================================*/ { + /* (1) Create clipped copy */ - $clip = \imagecreatetruecolor($width, $height); + $clip = \imagecreatetruecolor($width*$resize_factor, $height*$resize_factor); $copied = \imagecopyresized( - $clip, // destin img - $this->img_res, // source img - 0, // dest x - 0, // dest y - $start[0], // src x - $start[1], // src y - $width, // dest w - $height, // dest h - $width, // src w - $height // src h + $clip, // destin img + $this->img_res, // source img + 0, // dest x + 0, // dest y + $start[0], // src x + $start[1], // src y + $width*$resize_factor, // dest w + $height*$resize_factor, // dest h + $width, // src w + $height // src h ); /* (2) Manage copy error */ if( !$copied ) throw new \Exception("Cannot clip image"); - /* (3) Save to base64 */ + /* (3) Save to jpeg */ \imagesavealpha($clip, true); - ob_start(); - \imagejpeg($clip); - $image_data = \base64_encode(ob_get_contents()); - ob_end_clean(); + // ob_start(); + \imagejpeg($clip, $link); + // $image_data = \base64_encode(ob_get_contents()); + // ob_end_clean(); + + } + + + + /* [2] Apply Tesseract + =========================================================*/ { + + /* (1) Load image with tesseract */ + try{ + + $tesseract = new Tesseract($link); + $read = $tesseract->read(); + + /* (2) Manage error */ + }catch(\Exception $e){ + + $read = [ 'unkown', 'unknown' ]; + + } } - return $image_data; + + /* [3] End procedure + =========================================================*/ + /* (1) Remove file */ + unlink($link); + + /* (2) Return read value */ + return $read; + } @@ -389,11 +422,6 @@ =========================================================*/ foreach($this->event as $event_col=>$events){ - $type = "unknown"; - - if( isset($col_assoc[$event_col]) ) - $type = $col_assoc[$event_col]; - /* (2) For each event of each type ---------------------------------------------------------*/ foreach($events as $start_t=>$data){ @@ -402,8 +430,9 @@ $RAW .= "DTSTART:${start_t}\n"; $RAW .= "DTEND:${data[0]}\n"; $RAW .= "UID:$start_t-univ-pau-ics\n"; // required - $RAW .= "SUMMARY:$type\n"; - $RAW .= "ATTACH;ENCODING=BASE64;VALUE=BINARY;FILENAME=att.jpg:${data[1]}\n"; + $RAW .= "SUMMARY:${data[1]}\n"; + $RAW .= "LOCATION:${data[2]}\n"; + // $RAW .= "ATTACH;ENCODING=BASE64;VALUE=BINARY;FILENAME=att.jpg:${data[1]}\n"; $RAW .= "CATEGORIES: UPPA Calendar\n"; $RAW .= "END:VEVENT\n"; } diff --git a/build/service/Tesseract.php b/build/service/Tesseract.php index e025f62..c4da651 100755 --- a/build/service/Tesseract.php +++ b/build/service/Tesseract.php @@ -6,86 +6,81 @@ /* [1] Attributes =========================================================*/ - private $filename = null; - private $content = null; - private $course = null; - private $teacher = null; - private $room = null; + private $fname = null; /* (1) Constructs and initialise a readed file * + * @fname