From c34d57a872859e8f6799dceb41022b043490c6bd Mon Sep 17 00:00:00 2001 From: Pit Kleyersburg Date: Thu, 18 Feb 2016 09:37:13 +0100 Subject: [PATCH] Detect image orientation if the OCR supports it Fixes issue #47. --- src/documents/consumer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 98fedde09..12761e992 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -28,6 +28,9 @@ def image_to_string(args): self, png, lang = args with Image.open(os.path.join(self.SCRATCH, png)) as f: + if self.OCR.can_detect_orientation(): + orientation = self.OCR.detect_orientation(f, lang=lang) + f = f.rotate(orientation["angle"], expand=1) return self.OCR.image_to_string(f, lang=lang)