A simple Node.js API that removes backgrounds from images and returns the result as a base64 string.
- Upload images via API endpoint
- Process images to remove backgrounds using @imgly/background-removal-node
- Return processed images as base64 strings
- Simple web interface for testing
- Clone this repository
- Install dependencies:
npm installnpm startThe server will run at http://localhost:3000
POST /remove-background
Upload an image file with the key 'image' in a multipart/form-data request.
Example using curl:
curl -X POST -F "image=@/path/to/your/image.jpg" http://localhost:3000/remove-backgroundExample response:
{
"base64Image": "iVBORw0KGgoAAAANSUhEUgAA..." // base64 encoded image data
}A simple web interface is available at http://localhost:3000 for testing the API.
- express - Web server framework
- multer - File upload handling
- @imgly/background-removal-node - Background removal library
- cors - Cross-origin resource sharing
MIT