Building an Image Intelligence Bot: Reverse Search and Metadata from Telegram
How We Automated Metadata Extraction and Multi-Engine Reverse Image Search with a Telegram Bot
From the moment you drop a photo into a chat, a story unfolds.
This second post in our image investigation series documents the creation of a custom Telegram bot designed to extract metadata and run automated reverse image searches on Google, Bing, and Yandex. It combines lightweight Python scripting, clever use of browser automation, and integration with the Telegram API.
Let’s dive into how we built it, the challenges we faced, and how you can use it.
🧠 The Idea
We wanted a tool that:
Extracts image metadata (EXIF/GPS)
Converts HEIC files automatically
Uploads the image to Google, Bing, and Yandex for reverse image search
Returns clean, formatted results directly in a Telegram chat
The goal was to speed up the manual process of saving a photo, visiting multiple image search engines, uploading manually, and reviewing each result. This bot condenses that workflow into a single action: send an image to Telegram.
A single photo sent to the bot should yield:
Hidden metadata
Reverse image search results
Links and geolocation if available
🏗️ The Stack
Language: Python 3.11
Libraries:
pillow,pillow-heif,piexif,hachoir,selenium,undetected-chromedriver,python-telegram-botBrowsers: Headless Chromium (via undetected-chromedriver)
Platform: Telegram Bot API
🧰 Step-by-Step: How It Works
User sends a photo or image file to Telegram
The bot checks if it's a
.heic,.jpg, or.png.HEIC files are converted to JPEG automatically using
pillow-heif.
Metadata is extracted
piexifis used to extract EXIF data like GPS, date-time, aperture, ISO, and potentially even the device owner's name if embedded.GPS coordinates are converted to clickable Google Maps links.
hachoirparses deeper file metadata like compression details, dimensions, and creation timestamps.
Reverse image search automation
undetected-chromedriverlaunches a stealth browser to avoid bot detection.For each search engine:
The bot navigates to the image search page.
Locates the upload button using XPath.
Uploads the file.
Waits for the results page to load.
Scrapes result URLs for you to investigate.
Formatted results returned to Telegram
The bot sends a summary of:
All available metadata
Top 5 URLs from each engine
Google Maps link (if GPS is present)
🚧 Problems We Faced
1. Google Reverse Image Search Google blocks bots and changes its UI frequently. Buttons are unlabeled, and search result URLs are sometimes masked. We resolved this by:
Using XPath targeting text like "upload a file"
Scraping actual result links from the results panel
2. HEIC File Handling iPhones and other mobile devices default to .heic, which isn’t compatible with many libraries. We added:
Format detection logic
Conversion using
pillow-heif
3. Metadata Extraction Some EXIF tools only extract partial data. Our solution:
Combine
piexif(for GPS, camera settings) withhachoir(for everything else)
4. Async vs. Blocking Code Telegram bots are asynchronous, but browser automation isn’t. We handled this by:
Offloading blocking tasks to
ThreadPoolExecutorLetting the bot stay responsive while scraping
🧑💻 Use It Like an Investigator
For Regular Users:
🧳 Check Vacation Pics: Save the photo, then upload it to the bot. If the image has embedded GPS, the bot gives you a map link. Then it checks Yandex, Bing, and Google for visually similar images and sends links so you can dig deeper.
🔎 Debunk Scams: Got a photo from a suspicious profile or ad? Upload it and see where else it's appeared online.
🖼️ Find Original Artists: Trace reposted art or illustrations back to the creator.
For OSINT Analysts:
🌍 Geolocation: Use EXIF GPS or visual matches to find the place.
🤝 Link Personas: See if the same selfie is used across multiple accounts.
🧩 Timeline Building: Metadata reveals when the photo was taken, not just posted.
⚠️ Limitations
Google may block searches or return unusable redirect links
Metadata may be stripped or falsified
Messaging platforms like WhatsApp compress images and strip metadata. This is a good OPSEC practice, but limits investigation.
Reverse image results are probabilistic and not always explainable when using AI-based tools
Image coverage may be poor in less-developed regions due to sparse map/street photo data
🛠️ Try It or Build Your Own
Our full codebase is open on GitHub: github.com/rahu-protocol/image-search-bot
Clone it, run it locally, or deploy it for your own investigations.
🛡️ Use responsibly: This tool is for ethical investigation and research. Always respect privacy laws and platform terms of service.
If the first post taught you what images reveal, this one shows you how to extract it. Stay tuned for more.

