├── requirements.txt ├── LICENSE ├── README.md └── resize.py /requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Image Resizer For Telegram Stickers ⌛️ 2 | 3 | The Rev-Sticker is a Python script designed to automate the process of resizing images for creating stickers in Telegram. With this script, you can easily resize a batch of images to the required dimensions for Telegram stickers, saving you time and effort. 4 | 5 | ![](https://telegram.org/file/464001776/1/OT3p5F-BpWc.201999/cf29b6606b9abd380a) 6 | 7 | ## ✨ Features: 8 | 9 | Automatically resizes images for Telegram stickers. 10 | Supports resizing multiple images in a batch. 11 | Maintains aspect ratio while resizing to ensure the integrity of the original image. 12 | Convert other image formats to png. 13 | Simple and easy-to-use interface. 14 | 15 | 16 | ## ⚙️ Requirements 17 | 18 | - Python 3.x 19 | - [Pillow](https://python-pillow.org/) library 20 | 21 | ## Usage 💻 22 | 23 | 1. Clone the repository to your local machine using the following command: 24 | 25 | ```bash 26 | git clone https://github.com/revisto/rev-stickers.git 27 | cd rev-stickers 28 | 2. Put your images in the rev-stickers directory 29 | 30 | 3. Install Pillow by running the following command: 31 | 32 | ```bash 33 | pip3 install -r requirements.txt 34 | 4. Run the script by running the following command: 35 | 36 | ```bash 37 | python3 resize.py 38 | # 📄 License 39 | This project is licensed under the MIT License. -------------------------------------------------------------------------------- /resize.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def resize_images(folder_path, max_size=512): 5 | # Get a list of all files in the folder 6 | file_list = os.listdir(folder_path) 7 | 8 | # Iterate over each file in the folder 9 | for file_name in file_list: 10 | # Construct the full file path 11 | file_path = os.path.join(folder_path, file_name) 12 | 13 | # Check if the file is an image 14 | if file_name.lower().endswith(('.jpg', '.jpeg', '.png', '.gif')): 15 | try: 16 | # Open the image file using Pillow 17 | image = Image.open(file_path) 18 | if image.format != 'PNG': 19 | file_path = os.path.splitext(file_path)[0] + '.png' 20 | image.save(file_path, 'PNG') 21 | image = Image.open(file_path) 22 | # Calculate the new width and height while maintaining the aspect ratio 23 | width, height = image.size 24 | if width > height: 25 | new_width = max_size 26 | new_height = int(height * (new_width / width)) 27 | else: 28 | new_height = max_size 29 | new_width = int(width * (new_height / height)) 30 | 31 | # Resize the image 32 | resized_image = image.resize((new_width, new_height)) 33 | 34 | # Save the resized image, overwriting the original file 35 | resized_image.save(file_path) 36 | print(f"Resized {file_name} successfully.") 37 | except Exception as e: 38 | print(f"Failed to resize {file_name}: {str(e)}") 39 | else: 40 | print(f"Ignored {file_name} as it is not an image.") 41 | 42 | 43 | folder_path = '' # Replace with the actual folder path 44 | resize_images(folder_path) 45 | --------------------------------------------------------------------------------