import streamlit as st import svgwrite def apply_circle_mask(image_path): # Load image image = svgwrite.Drawing('output.svg') image.add(image.image(href=image_path, size=("100%", "100%"))) # Add circular mask width, height = image.viewbox[2:] half_x, half_y = width/2, height/2 line_color = "white" mask = image.defs.add(image.mask(id="bg_wrapper")) mask.add(image.circle(center=(half_x, half_y), r=335, fill=line_color, opacity=".4")) image.add(image.image(href=image_path, size=("100%", "100%"), mask="url(#bg_wrapper)")) return image.tostring() # Streamlit app st.title("Circular Image Mask") uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Save uploaded image to file with open("image.jpg", "wb") as f: f.write(uploaded_file.getbuffer()) # Apply circular mask and display result output_svg = apply_circle_mask("image.jpg") st.image(output_svg, output_format="SVG")