Following @fdasilva tweet about canvas functionality using streamlit here you have a case representing the need for implementing canvas ON TOP of pdfs.
Imagine you want to anotate pdfs manually. add notes. add colors. add annotations for your colleagues.
With Streamlit Drawable Canvas v0.4.0, you can now put a background image behind the canvas. You should be able to convert your pdf to an image in your app (maybe with pdf2image) and send it as argument of the canvas!
Hi. I want the drawable canvas to return a 3-dimensional numpy array instead of a 4-dimensional one so that I can overlay this on another image. Could you please help me out with it?
( Use case: I am asking the user to ‘sign’ in the canvas and I will be overlaying this on a prescription image - Doctor application)
Hey @Sharan19, the 4th channel is the alpha channel, you can delete it with some numpy manipulation:
canvas_result = st_canvas(background_color="#cec", height=100)
if canvas_result.image_data is not None:
st.image(canvas_result.image_data)
st.image(canvas_result.image_data[:,:,:3])
st.write(canvas_result.image_data)
st.write(canvas_result.image_data[:,:,:3])
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.