Advertisement
b-7

Termux Reverse Search/ Meta data

b-7
Mar 17th, 2023
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1.  
  2. import sys
  3. from PIL import Image
  4. from PIL.ExifTags import TAGS
  5.  
  6. def get_exif_data(image):
  7.     """Extract EXIF data from the image"""
  8.     try:
  9.         img = Image.open(image)
  10.         exif_data = img._getexif()
  11.         if exif_data is not None:
  12.             exif = {}
  13.             for tag, value in exif_data.items():
  14.                 decoded = TAGS.get(tag, tag)
  15.                 exif[decoded] = value
  16.             return exif
  17.         else:
  18.             return None
  19.     except:
  20.         return None
  21.  
  22. if __name__ == '__main__':
  23.     if len(sys.argv) > 1:
  24.         image = sys.argv[1]
  25.         exif_data = get_exif_data(image)
  26.         if exif_data is not None:
  27.             for key, val in exif_data.items():
  28.                 print(f"{key}: {val}")
  29.         else:
  30.             print("No EXIF data found in the image.")
  31.     else:
  32.         print("Usage: python extract_metadata.py <image>")
  33.  
  34.  
  35.  
  36.  
  37.  
  38. #!/data/data/com.termux/files/usr/bin/bash
  39.  
  40. echo "Enter the path of the image: "
  41. read path
  42.  
  43. #Extracting metadata
  44. exiftool $path
  45.  
  46. #Reverse image search option
  47. echo "Would you like to perform a reverse image search? (Y/N)"
  48. read choice
  49.  
  50. if [ "$choice" == "Y" ] || [ "$choice" == "y" ]
  51. then
  52.     xdg-open "https://www.google.com/searchbyimage?image_url=$(echo $path | sed 's/\//%2F/g' | sed 's/\+/%2B/g')"
  53. else
  54.     echo "Done"
  55. fi
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement