@@ -62,18 +62,19 @@ Python Script
6262.. code-block :: python
6363
6464 import exifread
65+
6566 # Open image file for reading (must be in binary mode)
66- f = open (path_name, ' rb ' )
67+ with open (file_path, " rb " ) as file_handle:
6768
68- # Return Exif tags
69- tags = exifread.process_file(f )
69+ # Return Exif tags
70+ tags = exifread.process_file(file_handle )
7071
7172 *Note: * To use this library in your project as a Git submodule, you should::
7273
7374 from <submodule_folder> import exifread
7475
7576Returned tags will be a dictionary mapping names of Exif tags to their
76- values in the file named by path_name .
77+ values in the file named by `` file_path `` .
7778You can process the tags as you wish. In particular, you can iterate through all the tags with:
7879
7980.. code-block :: python
@@ -119,13 +120,19 @@ Pass the ``-q`` or ``--quick`` command line arguments, or as:
119120
120121.. code-block :: python
121122
122- tags = exifread.process_file(f , details = False )
123+ tags = exifread.process_file(file_handle , details = False )
123124
124125 To process makernotes only, without extracting the thumbnail image (if any):
125126
126127.. code-block :: python
127128
128- tags = exifread.process_file(f, details = True , extract_thumbnail = False )
129+ tags = exifread.process_file(file_handle, details = True , extract_thumbnail = False )
130+
131+ To extract the thumbnail image (if any), without processing makernotes:
132+
133+ .. code-block :: python
134+
135+ tags = exifread.process_file(file_handle, details = False , extract_thumbnail = True )
129136
130137 Stop at a Given Tag
131138===================
@@ -136,7 +143,7 @@ Pass the ``-t TAG`` or ``--stop-tag TAG`` argument, or as:
136143
137144.. code-block :: python
138145
139- tags = exifread.process_file(f , stop_tag = ' TAG' )
146+ tags = exifread.process_file(file_handle , stop_tag = ' TAG' )
140147
141148 where ``TAG `` is a valid tag name, ex ``'DateTimeOriginal' ``.
142149
@@ -151,7 +158,7 @@ Pass the ``-s`` or ``--strict`` argument, or as:
151158
152159.. code-block :: python
153160
154- tags = exifread.process_file(f , strict = True )
161+ tags = exifread.process_file(file_handle , strict = True )
155162
156163 Usage Example
157164=============
@@ -168,8 +175,9 @@ This example shows how to use the library to correct the orientation of an image
168175 def _read_img_and_correct_exif_orientation (path ):
169176 im = Image.open(path)
170177 tags = {}
171- with open (path, ' rb' ) as f:
172- tags = exifread.process_file(f, details = False )
178+ with open (path, " rb" ) as file_handle:
179+ tags = exifread.process_file(file_handle, details = False )
180+
173181 if " Image Orientation" in tags.keys():
174182 orientation = tags[" Image Orientation" ]
175183 logging.basicConfig(level = logging.DEBUG )
@@ -195,9 +203,18 @@ This example shows how to use the library to correct the orientation of an image
195203 im = im.transpose(Image.ROTATE_90 )
196204 return im
197205
198- Credit
199- ******
200206
201- A huge thanks to all the contributors over the years!
207+ License
208+ *******
209+
210+ Copyright © 2002-2007 Gene Cash
211+
212+ Copyright © 2007-2023 Ianaré Sévi and contributors
213+
214+ A **huge ** thanks to all the contributors over the years!
202215
203216Originally written by Gene Cash & Thierry Bousch.
217+
218+ Available as open source under the terms of the **BSD-3-Clause license **.
219+
220+ See LICENSE.txt file for details.
0 commit comments