Skip to content

Commit

Permalink
Allow extracting thumbnails with details=False (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
angel6700 authored May 3, 2023
1 parent e975fa6 commit e6efa14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 9 additions & 4 deletions EXIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
#
# Copyright (c) 2002-2007 Gene Cash
# Copyright (c) 2007-2022 Ianaré Sévi and contributors
# Copyright (c) 2007-2023 Ianaré Sévi and contributors
#
# See LICENSE.txt file for licensing information
# See ChangeLog.rst file for all contributors and changes
Expand All @@ -25,7 +25,7 @@
logger = exif_log.get_logger()


def get_args():
def get_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
prog='EXIF.py',
description='Extract EXIF information from digital image files.'
Expand All @@ -41,7 +41,7 @@ def get_args():
)
parser.add_argument(
'-q', '--quick', action='store_false', dest='detailed',
help='Do not process MakerNotes',
help='Do not process MakerNotes and do not extract thumbnails',
)
parser.add_argument(
'-t', '--tag', type=str, dest='stop_tag',
Expand Down Expand Up @@ -87,7 +87,12 @@ def main(args) -> None:

# get the tags
data = process_file(
img_file, stop_tag=args.stop_tag, details=args.detailed, strict=args.strict, debug=args.debug
img_file,
stop_tag=args.stop_tag,
details=args.detailed,
strict=args.strict,
debug=args.debug,
extract_thumbnail=args.detailed
)

tag_stop = timeit.default_timer()
Expand Down
3 changes: 1 addition & 2 deletions exifread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def _determine_type(fh: BinaryIO) -> tuple:
elif data[0:8] == b'\x89PNG\r\n\x1a\n':
offset, endian = _find_png_exif(fh, data)
else:
# file format not recognized
raise ExifNotFound("File format not recognized.")
return offset, endian, fake_exif

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

# extract thumbnails
if details and thumb_ifd and extract_thumbnail:
if details or (thumb_ifd and extract_thumbnail):
hdr.extract_tiff_thumbnail(thumb_ifd)
hdr.extract_jpeg_thumbnail()

Expand Down

0 comments on commit e6efa14

Please sign in to comment.