Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heic/heif support #594

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ingestors/media/image.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from io import BytesIO
from PIL import Image, ExifTags
from pillow_heif import register_heif_opener
from followthemoney import model

from ingestors.ingestor import Ingestor
Expand Down Expand Up @@ -56,6 +57,7 @@ def extract_exif(self, img, entity):
entity.add("generator", value)

def ingest(self, file_path, entity):
register_heif_opener()
entity.schema = model.get("Image")
with open(file_path, "rb") as fh:
data = fh.read()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cchardet==2.1.7
lxml==5.0.0
olefile==0.47
Pillow==10.1.0
pillow-heif==0.15.0
vobject==0.9.6.1
msglite==0.30.0
icalendar==5.0.11
Expand Down
Binary file added tests/fixtures/image1.heic
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ def test_tesseract_ocr_regression(self):
image_entity.first("indexText"),
f"Test failed for {test_data[test_image_type]['file']}",
)

def test_ingest_heif(self):
fixture_path, entity = self.fixture("image1.heic")
self.manager.ingest(fixture_path, entity)

self.assertEqual(
entity.first("processingStatus"),
self.manager.STATUS_SUCCESS,
)
Loading