diff options
Diffstat (limited to 'libmat2/images.py')
| -rw-r--r-- | libmat2/images.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libmat2/images.py b/libmat2/images.py index 083ff64..e7cdf5a 100644 --- a/libmat2/images.py +++ b/libmat2/images.py | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import re | 2 | import re |
| 3 | from typing import Union, Any | 3 | from typing import Union, Any, Dict |
| 4 | 4 | ||
| 5 | import cairo | 5 | import cairo |
| 6 | 6 | ||
| @@ -48,7 +48,7 @@ class SVGParser(exiftool.ExiftoolParser): | |||
| 48 | surface.finish() | 48 | surface.finish() |
| 49 | return True | 49 | return True |
| 50 | 50 | ||
| 51 | def get_meta(self) -> dict[str, Union[str, dict]]: | 51 | def get_meta(self) -> Dict[str, Union[str, Dict]]: |
| 52 | meta = super().get_meta() | 52 | meta = super().get_meta() |
| 53 | 53 | ||
| 54 | # The namespace is mandatory, but only the …/2000/svg is valid. | 54 | # The namespace is mandatory, but only the …/2000/svg is valid. |
| @@ -57,6 +57,7 @@ class SVGParser(exiftool.ExiftoolParser): | |||
| 57 | meta.pop('Xmlns') | 57 | meta.pop('Xmlns') |
| 58 | return meta | 58 | return meta |
| 59 | 59 | ||
| 60 | |||
| 60 | class PNGParser(exiftool.ExiftoolParser): | 61 | class PNGParser(exiftool.ExiftoolParser): |
| 61 | mimetypes = {'image/png', } | 62 | mimetypes = {'image/png', } |
| 62 | meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', | 63 | meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', |
| @@ -156,11 +157,12 @@ class TiffParser(GdkPixbufAbstractParser): | |||
| 156 | 'FileTypeExtension', 'ImageHeight', 'ImageSize', | 157 | 'FileTypeExtension', 'ImageHeight', 'ImageSize', |
| 157 | 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'} | 158 | 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'} |
| 158 | 159 | ||
| 160 | |||
| 159 | class PPMParser(abstract.AbstractParser): | 161 | class PPMParser(abstract.AbstractParser): |
| 160 | mimetypes = {'image/x-portable-pixmap'} | 162 | mimetypes = {'image/x-portable-pixmap'} |
| 161 | 163 | ||
| 162 | def get_meta(self) -> dict[str, Union[str, dict]]: | 164 | def get_meta(self) -> Dict[str, Union[str, Dict]]: |
| 163 | meta = {} # type: dict[str, Union[str, dict[Any, Any]]] | 165 | meta = {} # type: Dict[str, Union[str, Dict[Any, Any]]] |
| 164 | with open(self.filename) as f: | 166 | with open(self.filename) as f: |
| 165 | for idx, line in enumerate(f): | 167 | for idx, line in enumerate(f): |
| 166 | if line.lstrip().startswith('#'): | 168 | if line.lstrip().startswith('#'): |
| @@ -176,9 +178,10 @@ class PPMParser(abstract.AbstractParser): | |||
| 176 | fout.write(line) | 178 | fout.write(line) |
| 177 | return True | 179 | return True |
| 178 | 180 | ||
| 181 | |||
| 179 | class HEICParser(exiftool.ExiftoolParser): | 182 | class HEICParser(exiftool.ExiftoolParser): |
| 180 | mimetypes = {'image/heic'} | 183 | mimetypes = {'image/heic'} |
| 181 | meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName','Directory', | 184 | meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', 'Directory', |
| 182 | 'FileSize', 'FileModifyDate', 'FileAccessDate', | 185 | 'FileSize', 'FileModifyDate', 'FileAccessDate', |
| 183 | 'FileInodeChangeDate', 'FilePermissions', 'FileType', | 186 | 'FileInodeChangeDate', 'FilePermissions', 'FileType', |
| 184 | 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion', | 187 | 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion', |
