Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jvoisin
mat2
Commits
704367f9
Commit
704367f9
authored
2 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Add support for HEIC files
Thanks to Maxime Morin (
https://www.maijin.fr/
) for the patch.
parent
26397137
No related branches found
No related tags found
No related merge requests found
Pipeline
#96302
passed with warnings
2 years ago
Stage: linting
Stage: test
Changes
4
Pipelines
9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libmat2/images.py
+20
-0
20 additions, 0 deletions
libmat2/images.py
libmat2/parser_factory.py
+4
-0
4 additions, 0 deletions
libmat2/parser_factory.py
tests/data/dirty.heic
+0
-0
0 additions, 0 deletions
tests/data/dirty.heic
tests/test_libmat2.py
+11
-0
11 additions, 0 deletions
tests/test_libmat2.py
with
35 additions
and
0 deletions
libmat2/images.py
+
20
−
0
View file @
704367f9
...
...
@@ -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
()
This diff is collapsed.
Click to expand it.
libmat2/parser_factory.py
+
4
−
0
View file @
704367f9
...
...
@@ -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
"""
...
...
This diff is collapsed.
Click to expand it.
tests/data/dirty.heic
0 → 100644
+
0
−
0
View file @
704367f9
File added
This diff is collapsed.
Click to expand it.
tests/test_libmat2.py
+
11
−
0
View file @
704367f9
...
...
@@ -251,6 +251,12 @@ class TestGetMeta(unittest.TestCase):
meta
=
p
.
get_meta
()
self
.
assertEqual
(
meta
[
'
Name
'
],
'
I am so
'
)
def
test_heic
(
self
):
p
=
images
.
HEICParser
(
'
./tests/data/dirty.heic
'
)
meta
=
p
.
get_meta
()
self
.
assertEqual
(
meta
[
'
ProfileCopyright
'
],
'
Public Domain
'
)
self
.
assertEqual
(
meta
[
'
ProfileDescription
'
],
'
GIMP built-in sRGB
'
)
class
TestRemovingThumbnails
(
unittest
.
TestCase
):
def
test_odt
(
self
):
...
...
@@ -504,6 +510,11 @@ class TestCleaning(unittest.TestCase):
'
EncodingSettings
'
:
'
Lavf52.103.0
'
,
},
'
expected_meta
'
:
{},
},{
'
name
'
:
'
heic
'
,
'
parser
'
:
images
.
HEICParser
,
'
meta
'
:
{},
'
expected_meta
'
:
{},
}
]
...
...
This diff is collapsed.
Click to expand it.
jvoisin
@jvoisin
mentioned in issue
#170 (closed)
·
2 years ago
mentioned in issue
#170 (closed)
mentioned in issue #170
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment