Backend: - Add /tools router with background removal, smart select, color select - Add rembg dependency for AI background removal - Add layer management API (list, flatten) - Fix transparency preservation in blend_patch (veil collapse fix) - Preserve alpha channel when reverting/resetting images Frontend: - Add AdvancedTools panel with background removal, smart select, color select - Add Layers panel with drag-to-reorder, visibility toggle, flatten - Add toolsApi for new backend endpoints - Make right panel scrollable for additional controls This adds "Photoshop light" capabilities: - Remove background and create layer - Smart object selection (click to select) - Color selection with tolerance - Layer system with compositing
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from contextlib import asynccontextmanager
|
|
|
|
from app.config import settings
|
|
from app.database import init_db
|
|
from app.routers import projects, edits, images, patches, generate, tools
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Initialize database on startup"""
|
|
init_db()
|
|
yield
|
|
|
|
|
|
app = FastAPI(
|
|
title="AI Photo Edit API",
|
|
description="API for AI-powered photo editing with mask-scoped regeneration",
|
|
version="1.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins_list,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(projects.router)
|
|
app.include_router(edits.router)
|
|
app.include_router(images.router)
|
|
app.include_router(patches.router)
|
|
app.include_router(generate.router)
|
|
app.include_router(tools.router)
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
"""API root endpoint"""
|
|
return {
|
|
"name": "AI Photo Edit API",
|
|
"version": "1.0.0",
|
|
"status": "running"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
"""Health check endpoint"""
|
|
return {"status": "healthy"}
|