--- /dev/null
+<?php
+
+namespace Cubist\Util\CommandLine;
+
+use Cubist\Util\CommandLine;
+
+class Docling extends CommandLine
+{
+ protected $_prog = 'docling';
+
+ public function __construct($output = null, $error = true, $outputPrefix = null)
+ {
+ parent::__construct('docling', $output, $error, $outputPrefix);
+ }
+
+ public static function OCR($image, $locale = null)
+ {
+ $out = $image . '.' . md5($locale) . '.md';
+ if (!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)) {
+ $cli = new self();
+ $cli->setArg('to', 'md');
+ if ($locale) {
+ $cli->setArg('ocr-lang', $locale);
+ }
+ $cli->setArg('output', $out);
+ $cli->setArg(null, $image);
+ $cli->execute();
+ }
+ return file_get_contents($out);
+ }
+}
\ No newline at end of file