Skip to content

Commit 2cc5a91

Browse files
committed
fixes
1 parent 8b30593 commit 2cc5a91

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

Diff for: exifread/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ def _find_heic_tiff(fh: BinaryIO) -> tuple:
3434
offset = fh.tell() - 4
3535
fh.seek(offset)
3636
endian = data[0:2]
37-
asterisk = data[2:4]
3837
offset = fh.tell()
39-
logger.debug(f'Found TIFF header in Exif, offset = {offset:0x}H')
38+
logger.debug('Found TIFF header in Exif, offset = %0xH', offset)
4039
else:
41-
raise InvalidExif("Exif pointer to zeros, but found {data} instead of a TIFF header.")
40+
raise InvalidExif(
41+
"Exif pointer to zeros, but found " + str(data) + " instead of a TIFF header."
42+
)
4243

4344
return offset, endian
4445

Diff for: exifread/heic.py

+27-30
Original file line numberDiff line numberDiff line change
@@ -263,39 +263,36 @@ def _parse_iloc(self, box: Box):
263263
extents.append((extent_offset, extent_length))
264264
box.locs[item_id] = extents
265265

266-
""" Added a few box names, which as unhandled aborted data extraction:
267-
hdlr, pitm, dinf, iprp, idat, iref
268-
Handling is initially NONE.
269-
They were found in .heif photo files produced by Nokia 8.3 5G.
270-
They are part of the standard, referring to:
271-
- ISO/IEC 14496-12 fifth edition 2015-02-20 (chapter 8.10 Metadata)
272-
found in: https://mpeg.chiariglione.org/standards/mpeg-4/iso-base-media-file-format/text-isoiec-14496-12-5th-edition
273-
(The newest is ISO/IEC 14496-12:2022, but would cost 208 Swiss Francs at iso.org)
274-
- A C++ example: https://exiv2.org/book/#BMFF
275-
"""
266+
# Added a few box names, which as unhandled aborted data extraction:
267+
# hdlr, pitm, dinf, iprp, idat, iref
268+
#
269+
# Handling is initially `None`.
270+
# They were found in .heif photo files produced by Nokia 8.3 5G.
271+
#
272+
# They are part of the standard, referring to:
273+
# - ISO/IEC 14496-12 fifth edition 2015-02-20 (chapter 8.10 Metadata)
274+
# found in:
275+
# https://mpeg.chiariglione.org/standards/mpeg-4/iso-base-media-file-format/text-isoiec-14496-12-5th-edition
276+
# (The newest is ISO/IEC 14496-12:2022, but would cost 208 Swiss Francs at iso.org)
277+
# - A C++ example: https://exiv2.org/book/#BMFF
278+
276279
def _parse_hdlr(self, box: Box):
277-
logger.debug("HEIC: found 'hdlr' Box, skipped")
278-
pass
280+
logger.debug("HEIC: found 'hdlr' Box %s, skipped", box.name)
279281

280282
def _parse_pitm(self, box: Box):
281-
logger.debug("HEIC: found 'pitm' Box, skipped")
282-
pass
283+
logger.debug("HEIC: found 'pitm' Box %s, skipped", box.name)
283284

284285
def _parse_dinf(self, box: Box):
285-
logger.debug("HEIC: found 'dinf' Box, skipped")
286-
pass
286+
logger.debug("HEIC: found 'dinf' Box %s, skipped", box.name)
287287

288288
def _parse_iprp(self, box: Box):
289-
logger.debug("HEIC: found 'iprp' Box, skipped")
290-
pass
289+
logger.debug("HEIC: found 'iprp' Box %s, skipped", box.name)
291290

292291
def _parse_idat(self, box: Box):
293-
logger.debug("HEIC: found 'idat' Box, skipped")
294-
pass
292+
logger.debug("HEIC: found 'idat' Box %s, skipped", box.name)
295293

296294
def _parse_iref(self, box: Box):
297-
logger.debug("HEIC: found 'iref' Box, skipped")
298-
pass
295+
logger.debug("HEIC: found 'iref' Box %s, skipped", box.name)
299296

300297
def find_exif(self) -> tuple:
301298
ftyp = self.expect_parse('ftyp')
@@ -304,7 +301,7 @@ def find_exif(self) -> tuple:
304301
meta = self.expect_parse('meta')
305302
assert meta.subs['iinf'].exif_infe is not None
306303
item_id = meta.subs['iinf'].exif_infe.item_id
307-
extents = meta.subs['iloc'].locs[item_id]
304+
extents = meta.subs['iloc'].locs[item_id]
308305
logger.debug('HEIC: found Exif location.')
309306
# we expect the Exif data to be in one piece.
310307
assert len(extents) == 1
@@ -319,15 +316,15 @@ def find_exif(self) -> tuple:
319316
exif_tiff_header_offset = self.get32()
320317

321318
if exif_tiff_header_offset == 0:
322-
""" This case was found in HMD Nokia 8.3 5G heic photos.
323-
The TIFF header just sits there without any 'Exif'.
324-
"""
319+
# This case was found in HMD Nokia 8.3 5G heic photos.
320+
# The TIFF header just sits there without any 'Exif'.
321+
325322
offset = 0
326323
endian = '?' # Haven't got Endian info yet
327-
else:
324+
else:
328325
assert exif_tiff_header_offset >= 6
329-
assert self.get(exif_tiff_header_offset)[-6:] == b'Exif\x00\x00'
326+
assert self.get(exif_tiff_header_offset)[-6:] == b'Exif\x00\x00'
330327
offset = self.file_handle.tell()
331-
endian = self.file_handle.read(1)
332-
328+
endian = str(self.file_handle.read(1))
329+
333330
return offset, endian

0 commit comments

Comments
 (0)