Files
TalkEdit/backend/background_removal.py

50 lines
1.4 KiB
Python
Raw Normal View History

2026-03-26 23:39:31 -06:00
#!/usr/bin/env python3
"""
Background removal operations (placeholder for Phase 5).
"""
import json
import sys
from pathlib import Path
# Add backend to path
sys.path.insert(0, str(Path(__file__).parent))
from services.background_removal import is_available, remove_background_on_export
def main():
if len(sys.argv) < 2:
print("Usage: python background_removal.py <command> [args...]", file=sys.stderr)
sys.exit(1)
command = sys.argv[1]
try:
if command == "is_available":
result = is_available()
print(json.dumps({"available": result}))
elif command == "remove_background_on_export":
if len(sys.argv) != 6:
print("Usage: python background_removal.py remove_background_on_export <input_path> <output_path> <replacement> <replacement_value>", file=sys.stderr)
sys.exit(1)
input_path = sys.argv[2]
output_path = sys.argv[3]
replacement = sys.argv[4]
replacement_value = sys.argv[5]
result = remove_background_on_export(input_path, output_path, replacement, replacement_value)
print(json.dumps({"output_path": result}))
else:
print(f"Unknown command: {command}", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(json.dumps({"error": str(e)}), file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()