A simple image cropper for Streamlit, with fixes added
Project description
Streamlit - Cropper
A Forked version of the original streamlit-cropper, with added fixes
Fixes:
should_resize_image=Falsenow works- Using manual box_function in box_algorithm will hence work as well
- Remove stroke width from overall crop dimension
Installation
pip install streamlit-cropper-fix
Example Usage
import streamlit as st
from streamlit_cropper import st_cropper
from PIL import Image
st.set_option('deprecation.showfileUploaderEncoding', False)
# Upload an image and set some options for demo purposes
st.header("Cropper Demo")
img_file = st.sidebar.file_uploader(label='Upload a file', type=['png', 'jpg'])
realtime_update = st.sidebar.checkbox(label="Update in Real Time", value=True)
box_color = st.sidebar.color_picker(label="Box Color", value='#0000FF')
aspect_choice = st.sidebar.radio(label="Aspect Ratio", options=["1:1", "16:9", "4:3", "2:3", "Free"])
aspect_dict = {
"1:1": (1, 1),
"16:9": (16, 9),
"4:3": (4, 3),
"2:3": (2, 3),
"Free": None
}
aspect_ratio = aspect_dict[aspect_choice]
if img_file:
img = Image.open(img_file)
if not realtime_update:
st.write("Double click to save crop")
# Get a cropped image from the frontend
cropped_img = st_cropper(img, realtime_update=realtime_update, box_color=box_color,
aspect_ratio=aspect_ratio)
# Manipulate cropped image at will
st.write("Preview")
_ = cropped_img.thumbnail((150,150))
st.image(cropped_img)
References
Acknowledgments
Big thanks to Turner Anderson, zoncrd and yanirs for their contributions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamlit_cropper_fix-0.4.1.tar.gz
(972.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_cropper_fix-0.4.1.tar.gz.
File metadata
- Download URL: streamlit_cropper_fix-0.4.1.tar.gz
- Upload date:
- Size: 972.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaeb60ce4af2f3b594f65081fdc6f33998b1b83bbacc6d6207af0b0f0d91624e
|
|
| MD5 |
fcff3cef4d2572d0900eb7095165961d
|
|
| BLAKE2b-256 |
576eb1aaa680c2a94675d538fa524c67e79dd00e48d94efbd17b0212381777bf
|
File details
Details for the file streamlit_cropper_fix-0.4.1-py3-none-any.whl.
File metadata
- Download URL: streamlit_cropper_fix-0.4.1-py3-none-any.whl
- Upload date:
- Size: 983.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2a35f7c959041525904e6e3be1243e5cfc30aa52c9ea968bb6e37c08a2c728
|
|
| MD5 |
254de561115de915c053ae719fa71278
|
|
| BLAKE2b-256 |
d9c9319a55b088381b3c54970cd1e4716fc70e566f660795b813c1a5005d4cf5
|