Decouple core photo cleaning logic for CLI and API reuse #2
Labels
No labels
needs-info
needs-triage
ready-for-agent
ready-for-human
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: tilltheend/unwrap-clothes#2
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Parent Map: #1 (Garment Photo Cleaner Web App [Map])
Question
How should the core processing logic in
unwrap_clothes.pybe decoupled or modularized so both the existing CLI and the new FastAPI backend inapp.pyshare the exact same encoding, prompt construction, OpenRouter API client, and Lanczos resolution restoration?Resolution
Core photo processing and OpenRouter API interaction logic has been extracted into a reusable module .
Architectural decisions
Resolution
Core photo processing and OpenRouter API interaction logic has been extracted into a reusable module
cleaner.py.Architectural decisions
clean_garmentand helper functions accept both file paths (str) and in-memory raw bytes (bytes), enabling the upcoming FastAPI web endpoint to stream image uploads directly without temporary disk files.restore_resolution_bytesresamples image bytes in memory back to source aspect ratio and pixel dimensions using Pillow Lanczos filter.clean_garmentreturns aCleanResultdataclass containing image bytes, media type, OpenRouter billing cost, dimensions, and rescale indicators.unwrap_clothes.pyretains identical CLI argument parsing, console output formats, exit codes, and re-exports symbols for backward compatibility.tests/test_cleaner.pyandtests/test_unwrap_clothes.pypassing 20/20 test cases.