3/29/2023 0 Comments File exif data viewer![]() ![]() ![]() If info is populated, then you loop over it and decode the Exif data and populate your exif_data dictionary before returning it. If _getexif() returns None, then you also set info to an empty dictionary. If it fails, it sets info to an empty dictionary. This function takes in the image path and attempts to extract the Exif data from it. You are now ready to learn about the get_exif_data() function: def get_exif_data(path):Įxtracts the EXIF information from the provided photo This dictionary maps the Exif name to a more readable name. Then you create a Python dictionary that holds all the Exif fields that you want to display. This is used in a file dialog that you will create later on to allow the user to select an image to load. The first half of this code is the imports you will need to make your application function. Here are the first few lines of code: # exif_viewer.py ![]() That is a good-sized chunk of code! It would be confusing to try and explain all of it at once, so to make things easier you will go over the code piece by piece. Window.update(exif_data.get(field, "No data")) If event = "Exit" or event = sg.WIN_CLOSED:Įxif_data = get_exif_data(image_path.absolute()) Window = sg.Window("Image information", elements) ![]() "Load image data", file_types=file_types, key="load", To get started, create a new file named exif_viewer.py and add this code: # exif_viewer.pyįile_types = [("(JPEG (*.jpg)", "*.jpg"),Įxtracts the Exif information from the provided photo When you get done writing your code, your Exif viewer will look like this: The first step is to find an image that has Exif data in it. Regardless of which way you end up going, you are now ready to write your GUI code! Creating a Simple Exif Viewer You can use virtualenv or Python’s built-in venv module. You may want to install these packages in a Python virtual environment. You can install them both using pip: python -m pip install pillow PySimpleGUI Getting Startedīoth Pillow and PySimpleGUI will need to be installed to be able to follow along with this tutorial. For this tutorial, you will use PySimpleGUI. However, there are some key data points that are more useful than others.įor those pieces of data, it’s nice to create a GUI so you can view it easily. You can get a lot of information about your images via the Exif data. The Pillow package gives you the ability to extract Exif (Exchangeable Image File Format) metadata from images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |