I am working on a python Flask project, in where the core idea is to verify the image uploaded by the user and make sure it's not fake or they are plagiarized.
The help i need regarding is - User uploads the pic of a plant , i want to make sure that , they have only taken the picture, not from internet or copied from another person in the same platform. I have some preliminary checks but they are not enough, can anyone advise me on what more can i do ? I have done these mentioned below:
A) Done image quality check
B) Web detection
C)Database duplicate detection
D)Using latitude and longitude (failed miserably, accuracy difference of 2KM)
E)Making sure the image is plant only
Since the location method is not working, i have that loophole, i don't need it to be super security level but as long something similar to accurate location detection or any similar technique to make sure the image is really from the user. Would love to have some advise. Below is the location extracting code from image uploaded. Thankyou !
What I have tried:
# EXIF extraction functions
def get_exif_data(image_path):
"""Get embedded EXIF data from image file using ExifRead."""
with open(image_path, 'rb') as image_file:
tags = exifread.process_file(image_file)
return tags
def get_gps_data(tags):
"""Extract GPS data from EXIF tags."""
gps_data = {}
gps_keys = ['GPS GPSLatitude', 'GPS GPSLatitudeRef', 'GPS GPSLongitude', 'GPS GPSLongitudeRef']
for key in gps_keys:
if key in tags:
gps_data[key] = tags[key]
return gps_data
def convert_to_degrees(value):
"""Convert GPS coordinates to degrees, avoiding zero division."""
def safe_div(num, den):
return float(num) / float(den) if den != 0 else 0
if len(value.values) != 3:
print("Incomplete GPS coordinate data.")
return None
d = safe_div(value.values[0].num, value.values[0].den)
m = safe_div(value.values[1].num, value.values[1].den)
s = safe_div(value.values[2].num, value.values[2].den)
return d + (m / 60.0) + (s / 3600.0)
def get_lat_lon(gps_data):
"""Extract latitude and longitude from GPS data."""
lat = None
lon = None
gps_latitude = gps_data.get('GPS GPSLatitude')
gps_latitude_ref = gps_data.get('GPS GPSLatitudeRef')
gps_longitude = gps_data.get('GPS GPSLongitude')
gps_longitude_ref = gps_data.get('GPS GPSLongitudeRef')
if gps_latitude and gps_latitude_ref and gps_longitude and gps_longitude_ref:
lat = convert_to_degrees(gps_latitude)
lon = convert_to_degrees(gps_longitude)
if lat is None or lon is None:
return None, None
if gps_latitude_ref.values[0] != 'N':
lat = -lat
if gps_longitude_ref.values[0] != 'E':
lon = -lon
return lat, lon
def extract_gps_from_image(image_path):
tags = get_exif_data(image_path)
gps_data = get_gps_data(tags)
lat, lon = get_lat_lon(gps_data)
return lat, lon