Issue
Taking the guide from ExifRead 3.0.0 which says that it can deal with HEIC images, and with the examples of How to work with HEIC image file types in Python, I tried to read metadata of a HEIC file:
p = Path(r'C:\Users\Admin\Pictures\Apple media files\gallery\202204')
l=list(p.glob('**/*.HEIC'))
print(l[0])
# Open image file for reading (must be in binary mode)
f = open(l[0], 'rb')
# Return Exif tags
# tags = exifread.process_file(f)
# tags
exifread.process_file(f)
C:\Users\Admin\Pictures\Apple media files\gallery\202204\IMG_1234.HEIC
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
c:\Users\Admin\anaconda3\envs\scrape\lib\site-packages\exifread\heic.py in get_parser(self, box)
170 try:
--> 171 return defs[box.name]
172 except (IndexError, KeyError) as err:
KeyError: 'hdlr'
The above exception was the direct cause of the following exception:
NoParser Traceback (most recent call last)
in
9 # tags
10
---> 11 exifread.process_file(f)
c:\Users\Admin\anaconda3\envs\scrape\lib\site-packages\exifread\__init__.py in process_file(fh, stop_tag, details, strict, debug, truncate_tags, auto_seek)
135
136 try:
--> 137 offset, endian, fake_exif = _determine_type(fh)
138 except ExifNotFound as err:
139 logger.warning(err)
c:\Users\Admin\anaconda3\envs\scrape\lib\site-packages\exifread\__init__.py in _determine_type(fh)
...
--> 173 raise NoParser(box.name) from err
174
175 def parse_box(self, box: Box) -> Box:
NoParser: hdlr
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
How can I reach the metadata of HEIC files with the "exifread" Python module?
Solution
This is just to share what I found on the net to fix this. Check HEIC processing error: hdlr on Apple Silicon #4.
Thus, you should downgrade to a version below 3.0.0:
(scrape) C:\Users\Admin>conda install -c conda-forge "exifread<3"
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\Admin\anaconda3\envs\scrape
added / updated specs:
- exifread[version='<3']
The following packages will be downloaded:
package | build
---------------------------|-----------------
exifread-2.3.2 | pyhd8ed1ab_0 35 KB conda-forge
------------------------------------------------------------
Total: 35 KB
The following packages will be DOWNGRADED:
exifread 3.0.0-pyhd8ed1ab_0 --> 2.3.2-pyhd8ed1ab_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
exifread-2.3.2 | 35 KB | ################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Restart the Kernel/file/VSCode to reload exifread in version 2.3.2, and it works:
C:\Users\Admin\Pictures\Apple media files\gallery\202204\IMG_1234.HEIC
{'Image Make': (0x010F) ASCII=Apple @ 146,
...,
...}
Answered By - questionto42
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.