Streamlit-cropper is a great component. It looks like it can crop a rectangular image only. Is there a way to draw and crop a polygon using this component?
I am aware of * streamlit-drawable-canvas component. However, the drawable canvas that it offers is quite small ( I think height can be just 150).
You can edit the height and width parameters of drawable canvas and use the polygon drawing mode then you’ll have to manually crop your image with the output drawn polygon (you can definitely check out streamlit-cropper source code for this)
Hi @andfanilo, I am able to change height and width of st_canvas now. Thanks a lot !
Actually, I had tried these parameters before creating this topic. However, the changes didn’t show up in the streamlit app just by clicking on ‘Rerun’ option in top right corner of the app. And so I thought this thing doesn’t work. Seeing your response, I reloaded the page this time after changing height & width and that’s when it worked. Seems like these parameters don’t take effect just with ‘Rerun’.
A question for polygon drawing mode. I get the below path with canvas_result.json_data[“objects”][0][“path”]. In this, is the data point with ‘M’ in it the point where polygon drawing was started? Are all 'L’s connecting data points that are drawn?
and does ‘z’ indicate end of polygon?
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.