filters/get-text-orientation doesn't work with recent tesseract (4.1.0)

Proposal

I think this patch will resolve the problem. Apparently neither -psm nor having /dev/* as file work for tesseract (and for that reason, /dev/stdout is not used either in the patch). I'm not certain what this script does though, so have a close look whether something breaks with the patch.

The filename next to mktemp was removed because mktemp tried to create the tmpfile inside /usr, which will fail due to permissions. With no explicit specified naming scheme, the tempfile will end up in /tmp, which should work always.

Problem

The original script yielded these errors:

$ cat ~/pictures/Screenshot_20191005_160647.png |./get-text-orientation
./get-text-orientation: line 62: $tmpfile: ambiguous redirect
read_params_file: Can't open 0
read_params_file: Can't open l
read_params_file: Can't open osd
Error, could not create TXT output file: Read-only file system

The patched version yields this:

$ cat pictures/Screenshot_20191005_160647.png | ./get-text-orientation
Page number: 0
Orientation in degrees: 180
Rotate: 180
Orientation confidence: 0.66
Script: Japanese
Script confidence: 0.85

Patch

diff --git a/filters/get-text-orientation b/filters/get-text-orientation
index 847f2c6..8d4b7f2 100755
--- a/filters/get-text-orientation
+++ b/filters/get-text-orientation
@@ -47,8 +47,8 @@ if test $? != 0; then
     exit 1
 fi

-tmpfile=$(mktemp -q .reorient.XXX)
-trap "rm -f $tmpfile" 0 1 2 15
+tmpfile=$(mktemp -q)
+trap "rm -f $tmpfile ${tmpfile}.osd" 0 1 2 15

 case "$engine" in
     */tesseract|tesseract)
@@ -66,7 +66,8 @@ case "$engine" in
         #  about ends up on standard error, but our caller looks
         #  for it on standard output.  Redirect to handle that.

-        $engine $tmpfile /dev/null -psm 0 -l osd 2>&1
+        $engine $tmpfile $tmpfile --psm 0 -l osd 2> /dev/null
+        cat ${tmpfile}.osd
         ;;

     */ocr-engine-getrotate)