GitHunt

OsCrop banner

๐Ÿ–ผ๏ธ OsCrop

OsCrop is a simple yet powerful open-source tool for:

  • ๐Ÿงผ Removing backgrounds from images (PNG, JPG, WEBP)
  • โœ‚๏ธ Automatically cropping the main object
  • ๐ŸŽฏ Outputting clean 512x512 images centered on transparent backgrounds

Made for creators and developers who want fast, clean asset extraction โ€” perfect for Telegram stickers, digital design, AI datasets, and more.


๐Ÿ“ธ Use Cases

Whether you're a creator, developer, or just someone working with digital visuals โ€” OsCrop simplifies your workflow.

  • ๐Ÿงฉ Creating Telegram, WhatsApp, or Discord stickers
  • ๐Ÿ›๏ธ Cleaning up product images for online shops
  • ๐Ÿง  Preparing consistent assets for machine learning datasets
  • ๐ŸŽจ Extracting and isolating emoji, clipart, avatars, or sprites
  • ๐Ÿ“š Streamlining bulk image cleanup for digital archives or design packs

โœจ Features

  • ๐Ÿ” Detects objects using alpha transparency or shape detection
  • ๐Ÿงผ Cleans up black glow or leftover outlines
  • ๐Ÿช„ Automatically centers and resizes objects onto transparent 512x512 canvases
  • ๐Ÿง  Skips previously processed images
  • ๐Ÿ” Full automation pipeline (removal + cropping)
  • ๐Ÿงฐ Supports PNG, JPG, and WEBP
  • ๐Ÿ” Includes author license check with anti-tamper

๐Ÿ“ Folder Structure

OsCrop/
โ”œโ”€โ”€ oscrop_full.py               # Full pipeline: background removal + crop + resize
โ”œโ”€โ”€ oscrop_bg_remover.py        # Only removes background using rembg
โ”œโ”€โ”€ oscrop_auto_alpha_crop.py   # Auto-crops transparent PNGs using alpha mask
โ”œโ”€โ”€ oscrop_crop_detect.py       # Crops non-transparent PNG/JPG/WEBP using object detection
โ”œโ”€โ”€ run_oscrop.py               # Easy launcher script for non-developers
โ”œโ”€โ”€ LICENSE                     # Os Public License v1.0
โ”œโ”€โ”€ README.md                   # You're reading it
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ””โ”€โ”€ samples/                    # Includes sample images for testing

๐Ÿ“ฆ Installation

Make sure you have Python 3.8 or higher installed.

pip install rembg opencv-python pillow numpy

โœ… Python 3.8 or higher recommended
โŒ No GPU required
๐Ÿ’ป Works on Windows, Mac, Linux (tested)


โš™๏ธ How to Use

python run_oscrop.py

This will show a menu to choose:

  1. Full Process
  2. Background Only
  3. Crop Transparent PNGs
  4. Crop Non-Transparent Images

Youโ€™ll be asked to set or confirm your input_folder.


2. Full Manual Scripts

Make sure to set input_folder in each script before running.

A. Full Pipeline

python oscrop_full.py

Creates output_no_bg/output_crops/

B. Just Remove Background

python oscrop_bg_remover.py

Creates output_no_bg/

C. Only Crop Transparent PNGs

python oscrop_auto_alpha_crop.py

Creates alpha_crops/ folder

D. Crop Non-Transparent Images

python oscrop_crop_detect.py

Creates shape_crops/ folder

๐Ÿ”„ If oscrop_auto_alpha_crop.py detects no alpha channel, it will skip and suggest using oscrop_crop_detect.py.
๐Ÿง  oscrop_crop_detect.py also skips full-sheet crops intelligently if they cover the whole image.


๐Ÿงช Output Samples

  • All cropped images are centered and padded into clean 512x512 boxes
  • Output folders like alpha_crops, shape_crops, output_crops are created automatically
  • Files are named sequentially like alpha_crop_1.png, detect_crop_3.png, etc

๐Ÿ“‚ Sample Images

Included in the samples/ folder:

  • dark_bg.png โ€“ Object sheet with dark background
  • white_bg.png โ€“ Object sheet with white background
  • transparent_sheet.png โ€“ PNG with alpha background

You can test the tools on these to see how they behave in different scenarios.


๐Ÿ“„ License

Os Public License v1.0
Copyright (c) 2025 Os (Osman Vision)

You are free to use, modify, and distribute the code,
BUT the author credit must remain visible.

Tampering with the license block or removing author lines
may result in broken functionality.

For commercial licensing, contact: heyosmanvision@gmail.com

๐Ÿ“ฌ Contact


๐Ÿ”ง Powered by OsCrop by Osman Vision