Use PIL in Python to extract only the data you want from Exif

Your photo is fake! When in doubt, most photos taken with a smartphone should have Exif data. Analyze photos with suspicious time series on Twitter etc. I think it can be used in various ways.

pilexif.py



#!/user/bin/env python
# -*- coding: utf-8 -*-
import sys
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS

def get_exif(file,field):

	img = Image.open(file)
	exif = img._getexif()

	
	exif_data = []
	for id, value in exif.items():
		if TAGS.get(id) == field:
			tag = TAGS.get(id, id),value
			exif_data.extend(tag)

	
	return exif_data

my_img = "sample.jpg "
print get_exif(my_img,"DateTimeOriginal")

Only specific data can be picked up by rewriting the part passed in the last print.

print get_exif(my_img,"DataTime")
print get_exif(my_img,"Model")

etc.

Recommended Posts

Use PIL in Python to extract only the data you want from Exif
I want to use the R dataset in python
I want to use jar from python
[Python] When you want to use all variables in another file
[Python] When you want to import and use your own package in the upper directory
If you want to use field names with hyphens when updating firestore data in python
If you want to count words in Python, it's convenient to use Counter.
How to use the C library in Python
I want to use ceres solver from python
I want to display the progress in Python!
I want to use Python in the environment of pyenv + pipenv on Windows 10
I wanted to use the Python library from MATLAB
I want to write in Python! (3) Utilize the mock
Let's use the open data of "Mamebus" in Python
How to use the model learned in Lobe in Python
The programming language you want to be able to use
If you use Pandas' Plot function in Python, it is really seamless from data processing to graph creation
Extract only complete from the result of Trinity
Remove the frame from the image
Computer Vision: Semantic Segmentation Part2 --Real-Time Semantic Segmentation
Let's cut the face from the image
Get only the text from the Django form.
Use Pillow to make the image transparent and overlay only part of it
Use PIL in Python to extract only the data you want from Exif
I want to extract only pods with the specified label using Label Selector in Client-go
Various ways to calculate the similarity between data in python
I want to use only the normalization process of SudachiPy
[Python] I want to use the -h option with argparse
Hit REST in Python to get data from New Relic
If you want your colleagues to use the same language
Pass OpenCV data from the original C ++ library to Python
Extract the value closest to a value from a Python list element
I know? Data analysis using Python or things you want to use when you want with numpy
Python canonical notation: How to determine and extract only valid date representations from input data
2015-12-26 python2> datetime> Implementation to take the difference in seconds from two ISO format datetime strings> Use .seconds ()
How to get only the data you need from a structured data set using a versatile method
Get data from Quandl in Python
How to use SQLite in Python
In the python command python points to python3.8
Extract text from images in Python
How to use Mysql in python
Use the Flickr API from Python
How to use ChemSpider in Python
How to use PubChem in Python
Extract strings from files in Python
[Subprocess] When you want to execute another Python program in Python code
Do you want to wait for general purpose in Python Selenium?
processing to use notMNIST data in Python (and tried to classify it)
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
How to use the asterisk (*) in Python. Maybe this is all? ..
[Introduction to Python] How to use the in operator in a for statement?
[Python / AWS Lambda layers] I want to reuse only module in AWS Lambda Layers
If you want to assign csv export to a variable in python
You can also use virtualenv from the IntelliJ IDEA Python plugin
What to do if you can't use the trash in Lubuntu 18.04.
Change the active version in Pyenv from anaconda to plain Python
I want to extract an arbitrary URL from the character string of the html source with python
When you want to use multiple versions of the same Python library (virtual environment using venv)
(Memo) Until you extract only the part you want from a certain Web page, convert it to a Sphinx page, and print it as a PDF
[Introduction to Python] How to use class in Python?
[Python] Use pandas to extract △△ that maximizes ○○
Use PostgreSQL data type (jsonb) from Python
Tips for Python beginners to use the Scikit-image example for themselves 9 Use from C
I want to send a signal only from the sub thread to the main thread
What to do if you can't use scikit grid search in Python
If you want to include awsebcli with CircleCI, specify the python version
Python Note: When you want to know the attributes of an object