Skip to content

PasinduSuraweera/ImaGen-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 ImaGen Editor

Python Streamlit Bria AI PIL

A modern, AI-powered image editor for professional background removal, shadow effects, and photo enhancement

Live Demo

FeaturesTech StackInstallationUsageAPI Integration


ImaGen Editor Preview

📋 Overview

ImaGen Editor is a cutting-edge web-based image editing application that harnesses the power of Bria AI to transform ordinary images into professional-quality visuals. Whether you're an e-commerce seller preparing product photos, a digital creator enhancing content, or a casual user looking to remove backgrounds, ImaGen Editor provides studio-quality results with just a few clicks.

Built on Streamlit for a seamless user experience and powered by Bria AI's advanced computer vision models, this tool eliminates the need for complex software like Photoshop while delivering comparable results.

✨ Features

🎨 Professional Background Editor

  • One-Click Background Removal - AI-powered subject isolation with pixel-perfect accuracy
  • Custom Background Colors - Apply any color to match your brand or style
  • Transparent Backgrounds - Perfect for logos, products, and overlay graphics
  • Smart Edge Detection - Preserves fine details like hair, fur, and transparent objects

🌫️ Advanced Shadow Effects

Add depth and realism to your images with professional shadow tools:

  • Drop Shadows - Classic shadow effects for emphasis
  • Natural Shadows - Realistic ground shadows for products
  • Customizable Parameters:
    • Shadow blur intensity
    • X/Y offset positioning
    • Shadow color selection
    • Opacity control (0-100%)
    • Shadow dimensions (width/height)

🛡️ Built-in Content Moderation

Optional AI-powered content filtering to ensure uploaded images meet community standards.

🏷️ SKU Management

Tag images with custom labels or Stock Keeping Units for inventory and organization.

🔍 Side-by-Side Preview

Instantly compare original and edited versions with real-time preview functionality.

⬇️ High-Quality Downloads

Export edited images in PNG format with full resolution and transparency support.

💻 Intuitive User Interface

  • Clean, modern design
  • Tabbed editing workflow
  • Expandable control panels
  • Responsive layout for all devices
  • Real-time processing feedback

🛠️ Tech Stack

Core Technologies

Technology Purpose Version
Python Primary programming language 3.8+
Streamlit Web application framework Latest
Bria AI AI-powered image processing API v1
Pillow Image manipulation library Latest

Supporting Libraries

Library Purpose
Requests HTTP client for API communication
Python-dotenv Environment variable management
Python-magic File type validation
Base64 Image encoding for API transmission
IO In-memory image operations

🏗️ System Architecture

┌─────────────────────────────────────────────────────────────┐
│                   STREAMLIT USER INTERFACE                  │
│                         (app.py)                            │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐ │
│  │  API Key     │  │  Background  │  │   Shadow         │ │
│  │  Settings    │  │  Editor Tab  │  │   Editor Tab     │ │
│  └──────────────┘  └──────────────┘  └──────────────────┘ │
│         │                 │                    │            │
│         └─────────────────┴────────────────────┘            │
│                           │                                 │
└───────────────────────────┼─────────────────────────────────┘
                            │
                     ┌──────▼──────┐
                     │  Components  │
                     │  - uploader  │
                     │  - preview   │
                     └──────┬──────┘
                            │
┌───────────────────────────▼─────────────────────────────────┐
│                    SERVICE LAYER                            │
│                                                             │
│  ┌─────────────────┐              ┌─────────────────────┐ │
│  │  Background     │              │  Shadow             │ │
│  │  Service        │              │  Service            │ │
│  │ (packshot.py)   │              │  (shadow.py)        │ │
│  └────────┬────────┘              └──────────┬──────────┘ │
│           │                                  │             │
│           └──────────────┬───────────────────┘             │
└──────────────────────────┼─────────────────────────────────┘
                           │
                    ┌──────▼──────┐
                    │  Bria AI    │
                    │     API     │
                    │             │
                    │  Endpoints: │
                    │  - /packshot│
                    │  - /shadow  │
                    │  - /rmbg    │
                    └──────┬──────┘
                           │
                    ┌──────▼──────┐
                    │  Processed  │
                    │   Images    │
                    │   (PNG)     │
                    └─────────────┘

🎯 How It Works

Phase 1: Image Upload & Validation 📤

  • User uploads image (PNG, JPG, JPEG)
  • File type validation using python-magic
  • Image preview displayed in interface
  • File converted to bytes for processing

Phase 2: Background Processing 🎨

Background Removal:

  1. Image encoded to base64
  2. Sent to Bria AI /background/remove endpoint
  3. AI analyzes image and isolates subject
  4. Returns processed image with transparent background

Color Application:

  1. Processed image sent to /packshot endpoint
  2. Custom background color applied
  3. Optional SKU tagging
  4. High-quality PNG generated

Phase 3: Shadow Enhancement 🌫️

  1. User selects shadow type (drop/natural)
  2. Customizes shadow parameters
  3. Image sent to /product/shadow endpoint
  4. AI generates realistic shadow effects
  5. Returns final composite image

Phase 4: Preview & Download ⬇️

  • Side-by-side comparison displayed
  • Download button for high-res PNG
  • Original preserved for further editing

☁️ Live Deployment

Experience ImaGen Editor in action:

https://imagen-image-background-generator.streamlit.app

Hosted on Streamlit Cloud for instant access without installation

📥 Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • Git
  • Bria AI API Key (Get it here)

Step-by-Step Setup

  1. Clone the repository
git clone https://github.com/PasinduSuraweera/ImaGen-App.git
cd ImaGen-App
  1. Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure API credentials

Create a .env file in the project root:

BRIA_API_KEY=your_bria_api_key_here
  1. Run the application
streamlit run app.py
  1. Access the application Open your browser and navigate to:
http://localhost:8501

📦 Required Dependencies

streamlit>=1.28.0
pillow>=10.0.0
requests>=2.31.0
python-dotenv>=1.0.0
python-magic>=0.4.27

🚀 Usage

Step 1: Configure API Key 🔑

Option A: Environment Variable (Recommended)

# In .env file
BRIA_API_KEY=your_api_key_here

Option B: Manual Entry

  • Open the sidebar in the app
  • Enter API key in the text field
  • Key is stored in session state

Step 2: Choose Your Editing Tool 🎨

Navigate between two powerful editors:

Background Editor Tab

Perfect for product photos, profile pictures, and graphics.

Shadow Editor Tab

Add professional depth and realism to isolated subjects.

Step 3: Upload Your Image 📤

  • Click "Upload Image" button
  • Select PNG, JPG, or JPEG file
  • Preview appears instantly
  • File validation ensures quality

Step 4: Customize Settings ⚙️

Background Editor Options:

  • Transparent Background - Remove background completely
  • 🎨 Background Color - Pick any hex color
  • 🏷️ SKU - Add product identifier (optional)

Shadow Editor Options:

  • 🌫️ Shadow Type - Drop or Natural
  • 🎨 Shadow Color - Choose shadow hue
  • 📏 Shadow Offset - X/Y positioning
  • 💡 Shadow Intensity - Opacity (0-100%)
  • 🌀 Shadow Blur - Softness level
  • 📐 Shadow Dimensions - Width/height control

Step 5: Process & Download 🚀

  1. Click "Process Image" button
  2. Wait for AI processing (2-5 seconds)
  3. View side-by-side comparison
  4. Click "Download" to save PNG

💡 Example Workflows

E-Commerce Product Photos

1. Upload product image with messy background
2. Enable "Transparent Background"
3. Process image
4. Switch to Shadow Editor
5. Add natural shadow with 70% intensity
6. Download final image for store listing

Profile Pictures

1. Upload portrait photo
2. Apply solid color background (#FFFFFF)
3. Process to remove original background
4. Download professional headshot

Logo Preparation

1. Upload logo on colored background
2. Enable transparent background
3. Process for clean isolation
4. Use in presentations and websites

📁 Project Structure

ImaGen-App/
│
├── app.py                          # Main Streamlit application
│
├── services/                       # Image processing services
│   ├── __init__.py
│   ├── packshot.py                # Background removal & color
│   ├── shadow.py                  # Shadow effects
│   └── background_service.py      # Background utilities
│
├── components/                     # UI components
│   ├── uploader.py                # File upload component
│   └── image_preview.py           # Preview component
│
├── assets/                         # Static assets
│   └── Screenshot3.png            # Preview image
│
├── .env                            # Environment variables (not in git)
├── .env.example                    # Environment template
├── .gitignore                      # Git ignore rules
├── requirements.txt                # Python dependencies
└── README.md                       # Project documentation

🔌 API Integration

ImaGen Editor integrates with Bria AI's powerful image processing APIs:

Background Removal Endpoint

POST https://engine.prod.bria-api.com/v1/background/remove

Purpose: Isolate subjects from backgrounds with AI precision

Packshot Creation Endpoint

POST https://engine.prod.bria-api.com/v1/product/packshot

Purpose: Apply custom backgrounds and prepare product photos

Shadow Addition Endpoint

POST https://engine.prod.bria-api.com/v1/product/shadow

Purpose: Add realistic drop or natural shadow effects

Authentication

All requests require an API token in headers:

headers = {
    'api_token': 'your_api_key',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
}

For detailed API documentation, visit Bria AI Docs

🎨 UI Design

Modern Interface

  • Clean, minimalist design
  • Professional color scheme
  • Intuitive navigation

Responsive Layout

  • Two-column comparison view
  • Expandable control panels
  • Mobile-friendly design

User Experience

  • Real-time feedback
  • Progress indicators
  • Error handling with clear messages
  • Keyboard shortcuts support

🔒 Security & Privacy

  • API keys stored securely in environment variables
  • No data retention - images processed in real-time
  • File validation prevents malicious uploads
  • HTTPS communication with API endpoints
  • Optional content moderation for safe uploads

⚡ Performance Features

  • 🚀 Fast API Response - 2-5 second processing time
  • 💾 Efficient Memory Usage - In-memory operations
  • 🔄 Session State Management - Preserves user data
  • 📦 Optimized Image Encoding - Base64 compression

🐛 Troubleshooting

Problem Solution
API Key Not Working Verify key is set in .env as BRIA_API_KEY
Upload Fails Ensure file is PNG, JPG, or JPEG format
API Error 422 Image may be blocked by content moderation
Image Not Displaying Check if valid image URL returned from API
Slow Processing Large images take longer; consider resizing
.env Not Loading Ensure .env file is in project root directory

🔮 Roadmap & Future Features

🚧 In Development

  • 🎨 Batch Processing - Edit multiple images at once
  • 📐 Image Resizing - Smart crop and resize tools
  • 🎭 Filter Effects - Apply artistic filters and adjustments
  • 💾 History Management - Undo/redo functionality

💡 Planned Features

  • 🖼️ Template Library - Pre-designed backgrounds and styles
  • 🎯 Smart Crop - AI-powered composition suggestions
  • 🌈 Color Palette Generator - Extract colors from images
  • 📊 Image Analytics - Size, dimensions, color analysis
  • 🔗 Direct Social Media Export - Share to platforms
  • 🎪 Advanced Effects - Blur, vignette, lighting
  • 📱 Mobile App - iOS and Android versions
  • 🤝 Collaboration Tools - Share and comment on edits

🤝 Contributing

Contributions are welcome! Help make ImaGen Editor even better.

How to Contribute:

  1. Fork the Project
  2. Create your Feature Branch
    git checkout -b feature/AmazingFeature
  3. Commit your Changes
    git commit -m 'Add some AmazingFeature'
  4. Push to the Branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Contribution Ideas:

  • 🎨 New image effects and filters
  • 🔧 Performance optimizations
  • 📚 Documentation improvements
  • 🐛 Bug fixes
  • 🌐 Internationalization
  • ♿ Accessibility enhancements

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

Pasindu Suraweera

🙏 Acknowledgments

  • 🎨 Bria AI - Powerful image processing APIs
  • 🚀 Streamlit - Rapid web app development
  • 🖼️ Pillow - Python imaging library
  • 🐍 Python - The language that powers it all
  • 💙 The open-source community

📞 Support

Need help or have questions?

📊 Use Cases

E-Commerce

  • Product photography
  • Catalog preparation
  • Marketplace listings
  • Ad creative

Content Creation

  • YouTube thumbnails
  • Social media graphics
  • Blog post images
  • Marketing materials

Professional Use

  • Headshots and portraits
  • Real estate photos
  • Resume pictures
  • Profile images

Design & Branding

  • Logo preparation
  • Brand assets
  • Presentation graphics
  • Print materials

If you find ImaGen Editor useful, please give it a star!

Made with 🎨 and ❤️ by Pasindu Suraweera

Visitors

Transform images with AI-powered precision 🚀

About

An AI-powered image editor built with Streamlit and Bria AI for professional background removal, custom backgrounds, and realistic shadow effects. Perfect for e-commerce, content creation, and photo editing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages