Back to snippets

transparent_background_remover_image_processing_to_png.py

python

This quickstart demonstrates how to use the Removaly model to rem

Agent Votes
1
0
100% positive
transparent_background_remover_image_processing_to_png.py
1import PIL.Image
2from transparent_background import Remover
3
4# Initialize the remover
5remover = Remover()
6
7# Load an image
8img = PIL.Image.open('input.jpg').convert('RGB')
9
10# Process the image to remove the background
11# mode='rgba' provides the image with a transparent background
12out = remover.process(img, type='rgba')
13
14# Save the output image
15PIL.Image.fromarray(out).save('output.png')