st-img-picker


Namest-img-picker JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryA Streamlit custom component for image selection with single and multi-selection support
upload_time2025-08-11 07:25:09
maintainerNone
docs_urlNone
authorPeter van Lunteren
requires_python!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # st-img-picker

**Fork of [streamlit-image-select](https://github.com/jrieke/streamlit-image-select) with multiple selection support.**

**A Streamlit custom component for image selection.**

This custom component works just like `st.selectbox` but with images. It's a great option
if you want to let the user select example images, e.g. for a computer vision app.

---

## Installation

```bash
pip install st-img-picker
```

## Simple usage

```python
import streamlit as st
from st_img_picker import img_picker

imgs = img_picker(
    "Select images", 
    ["image1.png", "image2.png", "image3.png"]
)
st.write(f"Selected {len(imgs)} images")
```

### Advanced usage
```python
from st_img_picker import img_picker
import numpy as np
from PIL import Image

# Mix different image types
imgs = img_picker(
    label="Choose your favorites",
    images=[
        "local/path/image.jpg",              # Local file
        "https://example.com/image.png",     # URL
        Image.open("another_image.jpg"),     # PIL Image
        np.array(Image.open("numpy.jpg"))    # NumPy array
    ],
    captions=["Local", "Remote", "PIL", "NumPy"],
    index=[0, 2],                            # Pre-select first and third
    use_container_width=True,
    return_value="index",                    # Return indices instead of images
    key="my_picker"
)

st.write(f"Selected indices: {imgs}")
```

## Parameters

- **label** (str): The label shown above the images.
- **images** (list): The images to show. Supports local files, URLs, PIL images, and numpy arrays.
- **captions** (list of str, optional): Captions to show below images. Defaults to None.
- **index** (int or list, optional): Initially selected image(s). For single selection: int. For multiple selection: list of ints. Defaults to [] for multi-select, 0 for single-select.
- **use_container_width** (bool, optional): Whether to stretch images to container width. Defaults to True.
- **return_value** ("original" or "index", optional): Return original objects or indices. Defaults to "original".
- **allow_multiple** (bool, optional): Enable multiple selection. Defaults to **True**.
- **key** (str, optional): Component key. Defaults to None.

## Returns

- **Multiple selection** (`allow_multiple=True`): Returns list of items (images or indices)
- **Single selection** (`allow_multiple=False`): Returns single item (image or index)

## Development

> **Warning**
> You only need to run these steps if you want to change this component or 
contribute to its development!

### Setup

First, clone the repository:

```bash
git clone <your-fork-repo-url>
cd st-img-picker
```

Install the Python dependencies:

```bash
poetry install --dev
```

And install the frontend dependencies:

```bash
cd st_img_picker/frontend
npm install
```

### Making changes

To make changes, first go to `st_img_picker/__init__.py` and make sure the 
variable `_RELEASE` is set to `False`. This will make the component use the local 
version of the frontend code, and not the built project. 

Then, start one terminal and run:

```bash
cd st_img_picker/frontend
npm start
```

This starts the frontend code on port 3001.

Open another terminal and run:

```bash
cp demo/streamlit_app.py .
poetry shell
streamlit run streamlit_app.py
```

This copies the demo app to the root dir (so you have something to work with and see 
your changes!) and then starts it. Now you can make changes to the Python or Javascript 
code in `st_img_picker` and the demo app should update automatically!

If nothing updates, make sure the variable `_RELEASE` in `st_img_picker/__init__.py` is set to `False`. 

### Publishing on PyPI

Switch the variable `_RELEASE` in `st_img_picker/__init__.py` to `True`. 
Increment the version number in `pyproject.toml`. Make sure the copy of the demo app in 
the root dir is deleted or merged back into the demo app in `demo/streamlit_app.py`.

Build the frontend code with:

```bash
cd st_img_picker/frontend
NODE_OPTIONS="--openssl-legacy-provider" npm run build
```

After this has finished, build and upload the package to PyPI:

```bash
cd ../..
poetry build
poetry publish
```

## License

MIT License - See LICENSE file for details.

## Credits

- Original [streamlit-image-select](https://github.com/jrieke/streamlit-image-select) by Johannes Rieke
- Fork enhancements by Peter van Lunteren

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "st-img-picker",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Peter van Lunteren",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/92/05/0ee1abdf2e9190bc20318924336e990246d7efa116798ce07a6a032da441/st_img_picker-1.0.2.tar.gz",
    "platform": null,
    "description": "# st-img-picker\n\n**Fork of [streamlit-image-select](https://github.com/jrieke/streamlit-image-select) with multiple selection support.**\n\n**A Streamlit custom component for image selection.**\n\nThis custom component works just like `st.selectbox` but with images. It's a great option\nif you want to let the user select example images, e.g. for a computer vision app.\n\n---\n\n## Installation\n\n```bash\npip install st-img-picker\n```\n\n## Simple usage\n\n```python\nimport streamlit as st\nfrom st_img_picker import img_picker\n\nimgs = img_picker(\n    \"Select images\", \n    [\"image1.png\", \"image2.png\", \"image3.png\"]\n)\nst.write(f\"Selected {len(imgs)} images\")\n```\n\n### Advanced usage\n```python\nfrom st_img_picker import img_picker\nimport numpy as np\nfrom PIL import Image\n\n# Mix different image types\nimgs = img_picker(\n    label=\"Choose your favorites\",\n    images=[\n        \"local/path/image.jpg\",              # Local file\n        \"https://example.com/image.png\",     # URL\n        Image.open(\"another_image.jpg\"),     # PIL Image\n        np.array(Image.open(\"numpy.jpg\"))    # NumPy array\n    ],\n    captions=[\"Local\", \"Remote\", \"PIL\", \"NumPy\"],\n    index=[0, 2],                            # Pre-select first and third\n    use_container_width=True,\n    return_value=\"index\",                    # Return indices instead of images\n    key=\"my_picker\"\n)\n\nst.write(f\"Selected indices: {imgs}\")\n```\n\n## Parameters\n\n- **label** (str): The label shown above the images.\n- **images** (list): The images to show. Supports local files, URLs, PIL images, and numpy arrays.\n- **captions** (list of str, optional): Captions to show below images. Defaults to None.\n- **index** (int or list, optional): Initially selected image(s). For single selection: int. For multiple selection: list of ints. Defaults to [] for multi-select, 0 for single-select.\n- **use_container_width** (bool, optional): Whether to stretch images to container width. Defaults to True.\n- **return_value** (\"original\" or \"index\", optional): Return original objects or indices. Defaults to \"original\".\n- **allow_multiple** (bool, optional): Enable multiple selection. Defaults to **True**.\n- **key** (str, optional): Component key. Defaults to None.\n\n## Returns\n\n- **Multiple selection** (`allow_multiple=True`): Returns list of items (images or indices)\n- **Single selection** (`allow_multiple=False`): Returns single item (image or index)\n\n## Development\n\n> **Warning**\n> You only need to run these steps if you want to change this component or \ncontribute to its development!\n\n### Setup\n\nFirst, clone the repository:\n\n```bash\ngit clone <your-fork-repo-url>\ncd st-img-picker\n```\n\nInstall the Python dependencies:\n\n```bash\npoetry install --dev\n```\n\nAnd install the frontend dependencies:\n\n```bash\ncd st_img_picker/frontend\nnpm install\n```\n\n### Making changes\n\nTo make changes, first go to `st_img_picker/__init__.py` and make sure the \nvariable `_RELEASE` is set to `False`. This will make the component use the local \nversion of the frontend code, and not the built project. \n\nThen, start one terminal and run:\n\n```bash\ncd st_img_picker/frontend\nnpm start\n```\n\nThis starts the frontend code on port 3001.\n\nOpen another terminal and run:\n\n```bash\ncp demo/streamlit_app.py .\npoetry shell\nstreamlit run streamlit_app.py\n```\n\nThis copies the demo app to the root dir (so you have something to work with and see \nyour changes!) and then starts it. Now you can make changes to the Python or Javascript \ncode in `st_img_picker` and the demo app should update automatically!\n\nIf nothing updates, make sure the variable `_RELEASE` in `st_img_picker/__init__.py` is set to `False`. \n\n### Publishing on PyPI\n\nSwitch the variable `_RELEASE` in `st_img_picker/__init__.py` to `True`. \nIncrement the version number in `pyproject.toml`. Make sure the copy of the demo app in \nthe root dir is deleted or merged back into the demo app in `demo/streamlit_app.py`.\n\nBuild the frontend code with:\n\n```bash\ncd st_img_picker/frontend\nNODE_OPTIONS=\"--openssl-legacy-provider\" npm run build\n```\n\nAfter this has finished, build and upload the package to PyPI:\n\n```bash\ncd ../..\npoetry build\npoetry publish\n```\n\n## License\n\nMIT License - See LICENSE file for details.\n\n## Credits\n\n- Original [streamlit-image-select](https://github.com/jrieke/streamlit-image-select) by Johannes Rieke\n- Fork enhancements by Peter van Lunteren\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Streamlit custom component for image selection with single and multi-selection support",
    "version": "1.0.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "84ee7465bf8de6b1cdc20e003658ad18c004f42f262082b6e98b11f61b9c51bc",
                "md5": "75d1338bdf50a2e1495996e5a98c91e8",
                "sha256": "3330dd09328260ab46e6ec0fe4df1114045ce6f3126c7c1684ec81f926685cbf"
            },
            "downloads": -1,
            "filename": "st_img_picker-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75d1338bdf50a2e1495996e5a98c91e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8",
            "size": 707567,
            "upload_time": "2025-08-11T07:25:08",
            "upload_time_iso_8601": "2025-08-11T07:25:08.075139Z",
            "url": "https://files.pythonhosted.org/packages/84/ee/7465bf8de6b1cdc20e003658ad18c004f42f262082b6e98b11f61b9c51bc/st_img_picker-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "92050ee1abdf2e9190bc20318924336e990246d7efa116798ce07a6a032da441",
                "md5": "3593d3bde8fa580b8e216bdc11528b15",
                "sha256": "edacbe2b713793cf12ac96231851250274fef483438d18c58f4b10bf70154cb5"
            },
            "downloads": -1,
            "filename": "st_img_picker-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3593d3bde8fa580b8e216bdc11528b15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8",
            "size": 696675,
            "upload_time": "2025-08-11T07:25:09",
            "upload_time_iso_8601": "2025-08-11T07:25:09.368159Z",
            "url": "https://files.pythonhosted.org/packages/92/05/0ee1abdf2e9190bc20318924336e990246d7efa116798ce07a6a032da441/st_img_picker-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-11 07:25:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "st-img-picker"
}
        
Elapsed time: 0.95563s