This project is an image processing service that uses a Telegram bot to interact with users. Users can send images to the bot and choose a filter to apply to the image. The bot then processes the image and sends it back to the user.
The project is structured as follows:
polybot/bot.py
: Contains theBot
,QuoteBot
, andImageProcessingBot
classes. TheBot
class is a simple echo bot, theQuoteBot
class extends theBot
class to quote incoming messages, and theImageProcessingBot
class extends theBot
class to process incoming photo messages.polybot/img_proc.py
: Contains theImg
class, which is used for image processing. TheImg
class has methods for various image filters, such as blur, contour, rotate, segment, salt and pepper, and concat.polybot/app.py
: The main entry point of the application. It's a Flask web server that uses an instance of theBot
class to handle incoming messages.polybot/test
: Contains unit tests for each filter and the Telegram bot.
The Img
class in polybot/img_proc.py
provides the following image filters:
blur()
: Blurs the image.contour()
: Applies a contour effect to the image.rotate()
: Rotates the image clockwise.segment()
: Partitions the image into regions where the pixels have similar attributes.salt_n_pepper()
: Adds "salt and pepper" noise to the image.concat()
: Concatenates two images together horizontally.
The ImageProcessingBot
class in polybot/bot.py
handles incoming photo messages from users. It processes the photos according to the caption field provided with the message and sends the processed image back to the user.
Before running the bot, make sure you have the following installed:
- Python 3.6 or later
- Ngrok (for exposing the local server to the internet)
This project is an image processing Telegram bot built with Python and the pyTelegramBotAPI library. The bot allows users to send photos, and it can perform various image processing operations on those photos, such as blurring, contouring, rotating, segmenting, adding salt and pepper noise, and concatenating images.
Before running the bot, make sure you have the following installed:
- Python 3.6 or later
- Ngrok (for exposing the local server to the internet)
- Clone the repository:
git clone https://github.com/CodesParadox/ImageProcessingService.git
- Navigate to the project directory:
cd ImageProcessingService
- Install the required dependencies:
pip install -r requirements.txt
-
Obtain a Telegram Bot token by creating a new bot using the BotFather on Telegram.
-
Install and authenticate Ngrok by following the instructions here.
-
Set the following environment variables:
TELEGRAM_TOKEN
: Your Telegram Bot token.TELEGRAM_APP_URL
: The public URL provided by Ngrok (leave it blank for now).
On Linux or macOS, you can set the environment variables like this:
export TELEGRAM_TOKEN="your_telegram_bot_token" export TELEGRAM_APP_URL=""
On Windows, use the following commands:
set TELEGRAM_TOKEN="your_telegram_bot_token" set TELEGRAM_APP_URL=""
- Start Ngrok with the following command:
ngrok http 8443
-
Copy the public URL provided by Ngrok (e.g.,
https://abcd.ngrok.io
). -
Update the
TELEGRAM_APP_URL
environment variable with the copied URL. -
Run the bot:
python app.py
- In the Telegram app, search for your bot and start sending photos to it. The bot will process the photos based on the provided captions and send back the processed images.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
This README provides an overview of the project, instructions for installation and configuration, steps to run the bot, a list of available filters, and information about contributing and licensing.
You can customize this README further by adding any additional details specific to your implementation, such as information about the `Img` class and its methods, examples of usage, or any other relevant information you'd like to include.
## Running the Bot
To run the bot, you need to set the `TELEGRAM_TOKEN` and `TELEGRAM_APP_URL` environment variables to your Telegram bot token and the public URL of your app, respectively. Then, you can run `polybot/app.py` to start the bot.
## Testing
You can run the unit tests in the `polybot/test` directory to test the image filters and the Telegram bot.
## Contributing
Contributions are welcome. Please feel free to submit a pull request or open an issue.# Image processing service