summaryrefslogtreecommitdiff
path: root/libmat2
diff options
context:
space:
mode:
authorjvoisin2022-05-15 18:57:27 +0200
committerjvoisin2022-05-15 18:57:27 +0200
commit704367f91eebe6158399f930f725334db96de134 (patch)
tree2a2f77e6e0b241b1120915df3608d961320072e7 /libmat2
parent263971370931b1c5b8c49ab287e6d30e40d974e2 (diff)
Add support for HEIC files
Thanks to Maxime Morin ( https://www.maijin.fr/ ) for the patch.
Diffstat (limited to '')
-rw-r--r--libmat2/images.py20
-rw-r--r--libmat2/parser_factory.py4
2 files changed, 24 insertions, 0 deletions
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):
181 line = re.sub(r"\s+", "", line, flags=re.UNICODE) 181 line = re.sub(r"\s+", "", line, flags=re.UNICODE)
182 fout.write(line) 182 fout.write(line)
183 return True 183 return True
184
185class HEICParser(exiftool.ExiftoolParser):
186 mimetypes = {'image/heic'}
187 meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName','Directory',
188 'FileSize', 'FileModifyDate', 'FileAccessDate',
189 'FileInodeChangeDate', 'FilePermissions', 'FileType',
190 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion',
191 'CompatibleBrands','HandlerType', 'PrimaryItemReference',
192 'HEVCConfigurationVersion', 'GeneralProfileSpace',
193 'GeneralTierFlag', 'GeneralProfileIDC',
194 'GenProfileCompatibilityFlags', 'ConstraintIndicatorFlags',
195 'GeneralLevelIDC', 'MinSpatialSegmentationIDC',
196 'ParallelismType','ChromaFormat', 'BitDepthLuma', 'BitDepthChroma',
197 'NumTemporalLayers', 'TemporalIDNested', 'ImageWidth',
198 'ImageHeight', 'ImageSpatialExtent', 'ImagePixelDepth',
199 'AverageFrameRate', 'ConstantFrameRate', 'MediaDataSize',
200 'MediaDataOffset','ImageSize', 'Megapixels'}
201
202 def remove_all(self) -> bool:
203 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')
11mimetypes.add_type('application/epub+zip', '.epub') 11mimetypes.add_type('application/epub+zip', '.epub')
12mimetypes.add_type('application/x-dtbncx+xml', '.ncx') # EPUB Navigation Control XML File 12mimetypes.add_type('application/x-dtbncx+xml', '.ncx') # EPUB Navigation Control XML File
13 13
14# This should be removed after we move to python3.10
15# https://github.com/python/cpython/commit/20a5b7e986377bdfd929d7e8c4e3db5847dfdb2d
16mimetypes.add_type('image/heic', '.heic')
17
14 18
15def __load_all_parsers(): 19def __load_all_parsers():
16 """ Loads every parser in a dynamic way """ 20 """ Loads every parser in a dynamic way """