Registry / web-framework / streamlit-image-coordinates

streamlit-image-coordinates

JSON →
library0.4.0pypypi✓ verified 84d ago

Streamlit-image-coordinates is a Streamlit component that displays an image and returns the coordinates when a user clicks on it. It also provides the click event time in Unix format. The current stable version is `0.4.0`, and the library is actively maintained with regular updates.

pip install streamlit-image-coordinates
INSTALL
IMPORT
SIG · STREAMLIT-IMAGE-CO
S
streamlit-image-coordinates
web-frameworkpythonv0.4.0
Install
15.5s avg
Import
1594ms
Disk
433MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.961s · 444.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 15.5s · import 1.227s · 414MB
433MB installed
● package 433MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

streamlit_image_coordinates
from streamlit_image_coordinates import streamlit_image_coordinates

This example demonstrates how to display an image and capture click coordinates using `streamlit_image_coordinates`. The returned `value` is a dictionary containing 'x', 'y', and optionally 'time'.

import streamlit as st from streamlit_image_coordinates import streamlit_image_coordinates st.title("Streamlit Image Coordinates Demo") st.write("Click on the image to get its coordinates:") value = streamlit_image_coordinates("https://placekitten.com/200/300") if value: st.write(f"Clicked at: x={value['x']}, y={value['y']}") if 'time' in value: st.write(f"Click time (Unix): {value['time']}") else: st.write("No click detected yet.")
Debug
Known issues
gotchaThe library is listed with a 'Development Status :: 3 - Alpha' on PyPI. While actively maintained, this implies that breaking changes could occur in future releases as the project matures.
fix
Refer to the official GitHub repository and PyPI release notes for updates and potential breaking changes when upgrading.
affects: <=0.4.0
gotchaUsing `streamlit_image_coordinates` for dynamic updates (e.g., drawing points on an image after a click) inside `st.form` might not work as expected and can be challenging to implement without `st.rerun()` or `st.experimental_fragment` which might break form submission logic.
fix
Consider structuring your app so that coordinate capture happens outside of a `st.form` context if dynamic updates are required, or manage state carefully within fragments. Refer to Streamlit community discussions for potential workarounds.
affects: All versions
gotchaFor older versions (prior to 0.1.3), updating an image dynamically after a click often required explicit use of `st.experimental_rerun()` to reflect changes. Newer versions (0.1.3 onwards) improved this behavior, reducing the need for manual reruns in many cases.
fix
Upgrade to version 0.1.3 or higher for improved dynamic update behavior. If still encountering issues, ensure state is managed with `st.session_state` and consider setting the `key` parameter to allow the component to update correctly.
affects: <0.1.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'streamlit_image_coordinates'
The `streamlit-image-coordinates` library is not installed in the current Python environment.
fix
pip install streamlit-image-coordinates
ImportError: cannot import name 'image_coordinates' from 'streamlit_image_coordinates'
The main function in the `streamlit_image_coordinates` package is named `streamlit_image_coordinates`, not `image_coordinates`.
fix
from streamlit_image_coordinates import streamlit_image_coordinates
StreamlitAPIException: Duplicate widgets with the same key found
You are calling `streamlit_image_coordinates()` multiple times in your app without providing a unique `key` argument for each instance, causing a conflict in Streamlit's state management.
fix
Ensure each call to `streamlit_image_coordinates()` has a unique `key` argument, for example: `streamlit_image_coordinates(image_source, key='image1')` and `streamlit_image_coordinates(image_source, key='image2')`.
TypeError: 'NoneType' object is not subscriptable
You are trying to access elements (like `coords['x']`) from the `coordinates` dictionary returned by `streamlit_image_coordinates()` before a user has clicked on the image, causing `coordinates` to be `None`.
fix
Always check if `coordinates` is not `None` before attempting to access its keys, for example: `if coordinates: st.write(f"Clicked at: {coordinates['x']}, {coordinates['y']}")`.
Upgrade
Version history
0.4.0latest on PyPI · released Aug 5, 2025
Audit
Dependencies
streamlitrequiredRequired for the component to function within a Streamlit application.
PillowoptionalOften used for image manipulation (e.g., drawing on images) when handling PIL Image objects with the component.
Agent activity
5 hits · last 30 days
node
4
Resources
streamlit-image-coordinates — pip install streamlit-image-coordinates · libregistry