attached: images
This commit is contained in:
parent
7fa39e90d3
commit
2d1f9a006f
|
@ -194,10 +194,10 @@
|
|||
|
||||
|
||||
// {5} If end reached //
|
||||
$this->event[$uid][$time] = $this->yToTime($day_n, $y);
|
||||
$this->event[$uid][$time] = [ $this->yToTime($day_n, $y) ];
|
||||
|
||||
// {6} Exctract event's image //
|
||||
$this->extractEvent("$time-$uid", [$col_x, $start_y+1], [$col_ind[$day_n+1]-1, $y]);
|
||||
$this->event[$uid][$time][1] = $this->extractEvent("$time-$uid", [$col_x, $start_y+1], [$col_ind[$day_n+1]-1, $y]);
|
||||
|
||||
|
||||
}
|
||||
|
@ -238,11 +238,13 @@
|
|||
public function extractEvent($uid, $start=null, $stop=null){
|
||||
|
||||
$link = __ROOT__."/tmp/$uid.jpeg";
|
||||
$width = $stop[0]-$start[0];
|
||||
$height = $stop[1]-$start[1];
|
||||
|
||||
/* [1] Get the right clip
|
||||
=========================================================*/ {
|
||||
/* (1) Create clipped copy */
|
||||
$clip = \imagecreatetruecolor($stop[0]-$start[0], $stop[1]-$start[1]);
|
||||
$clip = \imagecreatetruecolor($width, $height);
|
||||
|
||||
$copied = \imagecopyresized(
|
||||
$clip, // destin img
|
||||
|
@ -251,38 +253,29 @@
|
|||
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
|
||||
$width, // dest w
|
||||
$height, // dest h
|
||||
$width, // src w
|
||||
$height // src h
|
||||
);
|
||||
|
||||
/* (2) Manage copy error */
|
||||
if( !$copied )
|
||||
throw new \Exception("Cannot clip image");
|
||||
|
||||
/* (3) Save to file */
|
||||
/* (3) Save to base64 */
|
||||
\imagesavealpha($clip, true);
|
||||
|
||||
if( !\imagejpeg($clip, $link) )
|
||||
throw new \Exception("Cannot save image");
|
||||
ob_start();
|
||||
\imagejpeg($clip);
|
||||
$image_data = \base64_encode(ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [2] Process OCR
|
||||
=========================================================*/ {
|
||||
|
||||
/* (1) Creates a Tesseract (OCR) instance */
|
||||
// $ocr = new Tesseract($link);
|
||||
|
||||
/* (2) Reads from file */
|
||||
// $ocr->read();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $image_data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -403,13 +396,14 @@
|
|||
|
||||
/* (2) For each event of each type
|
||||
---------------------------------------------------------*/
|
||||
foreach($events as $start_t=>$stop_t){
|
||||
foreach($events as $start_t=>$data){
|
||||
$RAW .= "BEGIN:VEVENT\n";
|
||||
$RAW .= "DTSTAMP:".gmdate("Ymd\THis\Z", time())."\n"; // required
|
||||
$RAW .= "DTSTART:${start_t}\n";
|
||||
$RAW .= "DTEND:${stop_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 .= "CATEGORIES: UPPA Calendar\n";
|
||||
$RAW .= "END:VEVENT\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue