How to Remove EXIF Data from an Image using Python
When it comes to internet security, you can never be too careful: malicious actors online will often go after any available information they can gather to form a clearer picture about their potential victim. That includes geolocational data, which is a component of the EXIF metadata often included in images taken on our phones or other personal cameras. Thankfully, removing EXIF data can be accomplished easily with our EXIF removal API. This API will delete any EXIF data and profiles attached to a given image, ensuring the file can’t put you at risk when shared publicly. You can take advantage of this API for free with a free-tier Cloudmersive API key (obtainable by registering a free account on our website). Let’s walk through how to structure your API call using Python code examples below.
We’ll start by running the following command to install the Python SDK:
pip install cloudmersive-image-api-client
After that, we’ll add the imports:
from __future__ import print_function
import time
import cloudmersive_image_api_client
from cloudmersive_image_api_client.rest import ApiException
from pprint import pprint
Next, let’s include the snippet which captures your API key and finish calling the function:
# Configure API key authorization: Apikey
configuration = cloudmersive_image_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_image_api_client.EditApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/inputfile' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try:
# Remove EXIF data from the image
api_response = api_instance.edit_remove_exif_data(image_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling EditApi->edit_remove_exif_data: %s\n" % e)
Now you’re all done — no further code required. Nice and easy.