namespace Cubist\Util\CommandLine;
use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
class Docling extends CommandLine
{
public static function OCR($image, $locale = null)
{
- $out = $image . '.' . md5($locale) . '.md';
+ $f = new \SplFileInfo($image);
+
+ $out = $image . '.' . md5($locale) . '.html';
if (!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)) {
+ $tmp = Files::tmpdir();
$cli = new self();
$cli->setArg('to', 'md');
if ($locale) {
$cli->setArg('ocr-lang', $locale);
}
- $cli->setArg('output', $out);
+ $cli->setArg('output', $tmp);
$cli->setArg(null, $image);
$cli->execute();
+
+ $md = $tmp . '/' . $f->getBasename('.md');
}
return file_get_contents($out);
}
return $str;
}
+ public static function mtime($url){
+ $h = get_headers($url, 1);
+
+ $dt = NULL;
+ if (!($h || strstr($h[0], '200') === FALSE)) {
+ $dt = new \DateTime($h['Last-Modified']);
+ return $dt->getTimestamp();
+ }
+
+ }
}