mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: overhaul remove-background with effects pipeline, consolidate color tools
Remove Background: - Two-phase flow: AI removes bg once, then effects adjust instantly - Blur background effect with real-time CSS preview (portrait mode) - Drop shadow effect with opacity control - Gradient backgrounds with presets, custom colors, and angle - Custom background image upload (including HEIC/HEIF) - Solid color backgrounds moved from Python to Node.js/Sharp - Effects-only API endpoint for instant re-renders without AI re-run - HEIC/HEIF input support (decoded before passing to Python/rembg) - Passport/ID photo checkbox defaults ON for People subject - Before/after slider preserved when no effects active - 15 comprehensive Playwright e2e tests Color Tools: - Consolidated 4 tools (brightness-contrast, saturation, color-channels, color-effects) into single "Adjust Colors" tool - Added exposure, temperature, tint, hue, sharpness controls - SVG filter-based live preview for all adjustments - Backward-compatible URL redirects from old tool paths Other fixes: - Favicon tool: download button instead of auto-download - Batch processing: HEIC filename extension fix - File store: processedFilename field for proper batch downloads
This commit is contained in:
@@ -15,7 +15,6 @@ def main():
|
||||
settings = json.loads(sys.argv[3]) if len(sys.argv) > 3 else {}
|
||||
|
||||
model = settings.get("model", "birefnet-general-lite")
|
||||
bg_color = settings.get("backgroundColor", "")
|
||||
|
||||
# Redirect stdout to stderr so library download/progress output
|
||||
# cannot contaminate our JSON result on stdout.
|
||||
@@ -25,7 +24,6 @@ def main():
|
||||
try:
|
||||
from rembg import remove, new_session
|
||||
from gpu import onnx_providers
|
||||
import io
|
||||
|
||||
emit_progress(10, "Loading model")
|
||||
|
||||
@@ -51,21 +49,8 @@ def main():
|
||||
|
||||
emit_progress(80, "Background removed")
|
||||
|
||||
# If a background color is specified, composite onto it
|
||||
if bg_color and bg_color.startswith("#"):
|
||||
emit_progress(85, "Compositing background")
|
||||
from PIL import Image
|
||||
|
||||
img = Image.open(io.BytesIO(output_data)).convert("RGBA")
|
||||
hex_color = bg_color.lstrip("#")
|
||||
r = int(hex_color[0:2], 16)
|
||||
g = int(hex_color[2:4], 16)
|
||||
b = int(hex_color[4:6], 16)
|
||||
bg = Image.new("RGBA", img.size, (r, g, b, 255))
|
||||
bg.paste(img, mask=img.split()[3])
|
||||
buf = io.BytesIO()
|
||||
bg.save(buf, format="PNG")
|
||||
output_data = buf.getvalue()
|
||||
# Always return transparent PNG. All background compositing
|
||||
# (solid color, gradient, blur, shadow) is handled by Node.js/Sharp.
|
||||
|
||||
emit_progress(95, "Saving result")
|
||||
with open(output_path, "wb") as f:
|
||||
|
||||
Reference in New Issue
Block a user