mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #52 from pitkley/fix/detect-orientation-errors
Ignore error if orientation detection fails
This commit is contained in:
		| @@ -17,6 +17,7 @@ from PIL import Image | |||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.utils import timezone | from django.utils import timezone | ||||||
| from django.template.defaultfilters import slugify | from django.template.defaultfilters import slugify | ||||||
|  | from pyocr.tesseract import TesseractError | ||||||
|  |  | ||||||
| from logger.models import Log | from logger.models import Log | ||||||
| from paperless.db import GnuPG | from paperless.db import GnuPG | ||||||
| @@ -29,8 +30,11 @@ def image_to_string(args): | |||||||
|     self, png, lang = args |     self, png, lang = args | ||||||
|     with Image.open(os.path.join(self.SCRATCH, png)) as f: |     with Image.open(os.path.join(self.SCRATCH, png)) as f: | ||||||
|         if self.OCR.can_detect_orientation(): |         if self.OCR.can_detect_orientation(): | ||||||
|  |             try: | ||||||
|                 orientation = self.OCR.detect_orientation(f, lang=lang) |                 orientation = self.OCR.detect_orientation(f, lang=lang) | ||||||
|                 f = f.rotate(orientation["angle"], expand=1) |                 f = f.rotate(orientation["angle"], expand=1) | ||||||
|  |             except TesseractError: | ||||||
|  |                 pass | ||||||
|         return self.OCR.image_to_string(f, lang=lang) |         return self.OCR.image_to_string(f, lang=lang) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel Quinn
					Daniel Quinn