From 704367f91eebe6158399f930f725334db96de134 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 15 May 2022 18:57:27 +0200 Subject: Add support for HEIC files Thanks to Maxime Morin ( https://www.maijin.fr/ ) for the patch. --- libmat2/images.py | 20 ++++++++++++++++++++ libmat2/parser_factory.py | 4 ++++ 2 files changed, 24 insertions(+) (limited to 'libmat2') diff --git a/libmat2/images.py b/libmat2/images.py index 3da2673..9c24998 100644 --- a/libmat2/images.py +++ b/libmat2/images.py @@ -181,3 +181,23 @@ class PPMParser(abstract.AbstractParser): line = re.sub(r"\s+", "", line, flags=re.UNICODE) fout.write(line) return True + +class HEICParser(exiftool.ExiftoolParser): + mimetypes = {'image/heic'} + meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName','Directory', + 'FileSize', 'FileModifyDate', 'FileAccessDate', + 'FileInodeChangeDate', 'FilePermissions', 'FileType', + 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion', + 'CompatibleBrands','HandlerType', 'PrimaryItemReference', + 'HEVCConfigurationVersion', 'GeneralProfileSpace', + 'GeneralTierFlag', 'GeneralProfileIDC', + 'GenProfileCompatibilityFlags', 'ConstraintIndicatorFlags', + 'GeneralLevelIDC', 'MinSpatialSegmentationIDC', + 'ParallelismType','ChromaFormat', 'BitDepthLuma', 'BitDepthChroma', + 'NumTemporalLayers', 'TemporalIDNested', 'ImageWidth', + 'ImageHeight', 'ImageSpatialExtent', 'ImagePixelDepth', + 'AverageFrameRate', 'ConstantFrameRate', 'MediaDataSize', + 'MediaDataOffset','ImageSize', 'Megapixels'} + + def remove_all(self) -> bool: + return self._lightweight_cleanup() diff --git a/libmat2/parser_factory.py b/libmat2/parser_factory.py index 9965432..a539d12 100644 --- a/libmat2/parser_factory.py +++ b/libmat2/parser_factory.py @@ -11,6 +11,10 @@ T = TypeVar('T', bound='abstract.AbstractParser') mimetypes.add_type('application/epub+zip', '.epub') mimetypes.add_type('application/x-dtbncx+xml', '.ncx') # EPUB Navigation Control XML File +# This should be removed after we move to python3.10 +# https://github.com/python/cpython/commit/20a5b7e986377bdfd929d7e8c4e3db5847dfdb2d +mimetypes.add_type('image/heic', '.heic') + def __load_all_parsers(): """ Loads every parser in a dynamic way """ -- cgit v1.3