Skip to content

Commit e6efa14

Browse files
authored
Allow extracting thumbnails with details=False (#170)
1 parent e975fa6 commit e6efa14

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

EXIF.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
#
88
# Copyright (c) 2002-2007 Gene Cash
9-
# Copyright (c) 2007-2022 Ianaré Sévi and contributors
9+
# Copyright (c) 2007-2023 Ianaré Sévi and contributors
1010
#
1111
# See LICENSE.txt file for licensing information
1212
# See ChangeLog.rst file for all contributors and changes
@@ -25,7 +25,7 @@
2525
logger = exif_log.get_logger()
2626

2727

28-
def get_args():
28+
def get_args() -> argparse.Namespace:
2929
parser = argparse.ArgumentParser(
3030
prog='EXIF.py',
3131
description='Extract EXIF information from digital image files.'
@@ -41,7 +41,7 @@ def get_args():
4141
)
4242
parser.add_argument(
4343
'-q', '--quick', action='store_false', dest='detailed',
44-
help='Do not process MakerNotes',
44+
help='Do not process MakerNotes and do not extract thumbnails',
4545
)
4646
parser.add_argument(
4747
'-t', '--tag', type=str, dest='stop_tag',
@@ -87,7 +87,12 @@ def main(args) -> None:
8787

8888
# get the tags
8989
data = process_file(
90-
img_file, stop_tag=args.stop_tag, details=args.detailed, strict=args.strict, debug=args.debug
90+
img_file,
91+
stop_tag=args.stop_tag,
92+
details=args.detailed,
93+
strict=args.strict,
94+
debug=args.debug,
95+
extract_thumbnail=args.detailed
9196
)
9297

9398
tag_stop = timeit.default_timer()

exifread/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def _determine_type(fh: BinaryIO) -> tuple:
116116
elif data[0:8] == b'\x89PNG\r\n\x1a\n':
117117
offset, endian = _find_png_exif(fh, data)
118118
else:
119-
# file format not recognized
120119
raise ExifNotFound("File format not recognized.")
121120
return offset, endian, fake_exif
122121

@@ -180,7 +179,7 @@ def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
180179
hdr.decode_maker_note()
181180

182181
# extract thumbnails
183-
if details and thumb_ifd and extract_thumbnail:
182+
if details or (thumb_ifd and extract_thumbnail):
184183
hdr.extract_tiff_thumbnail(thumb_ifd)
185184
hdr.extract_jpeg_thumbnail()
186185

0 commit comments

Comments
 (0)