Enhancement: support heic images (#9771)

This commit is contained in:
shamoon 2025-04-23 09:22:21 -07:00 committed by GitHub
parent 5a278381e3
commit 00050f7c7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 0 deletions

View File

@ -108,6 +108,7 @@ class RasterisedDocumentParser(DocumentParser):
"image/bmp",
"image/gif",
"image/webp",
"image/heic",
]
def has_alpha(self, image) -> bool:

View File

@ -16,5 +16,6 @@ def tesseract_consumer_declaration(sender, **kwargs):
"image/gif": ".gif",
"image/bmp": ".bmp",
"image/webp": ".webp",
"image/heic": ".heic",
},
}

Binary file not shown.

View File

@ -880,6 +880,12 @@ class TestParserFileTypes(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
self.assertIsFile(parser.archive_path)
self.assertIn("this is a test document", parser.get_text().lower())
def test_heic(self):
parser = RasterisedDocumentParser(None)
parser.parse(os.path.join(self.SAMPLE_FILES, "simple.heic"), "image/heic")
self.assertIsFile(parser.archive_path)
self.assertIn("pizza", parser.get_text().lower())
@override_settings(OCR_IMAGE_DPI=200)
def test_gif(self):
parser = RasterisedDocumentParser(None)