{"id":14970842,"url":"https://github.com/olucaslopes/streamlit-paste-button","last_synced_at":"2025-09-11T16:37:12.319Z","repository":{"id":215787258,"uuid":"736933485","full_name":"olucaslopes/streamlit-paste-button","owner":"olucaslopes","description":"Paste an image with a button click and do whatever you want in your streamlit app!","archived":false,"fork":false,"pushed_at":"2024-01-10T07:14:27.000Z","size":1063,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-24T14:29:43.222Z","etag":null,"topics":["streamlit","streamlit-component"],"latest_commit_sha":null,"homepage":"https://paste-button.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olucaslopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-29T09:49:51.000Z","updated_at":"2024-04-11T15:31:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"42e6360c-2176-4910-9bdc-fbd6cc7a6385","html_url":"https://github.com/olucaslopes/streamlit-paste-button","commit_stats":null,"previous_names":["olucaslopes/streamlit-paste-button"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olucaslopes%2Fstreamlit-paste-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olucaslopes%2Fstreamlit-paste-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olucaslopes%2Fstreamlit-paste-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olucaslopes%2Fstreamlit-paste-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olucaslopes","download_url":"https://codeload.github.com/olucaslopes/streamlit-paste-button/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862885,"owners_count":16555951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["streamlit","streamlit-component"],"created_at":"2024-09-24T13:44:13.656Z","updated_at":"2024-10-11T04:42:01.905Z","avatar_url":"https://github.com/olucaslopes.png","language":"Python","readme":"# Streamlit - Paste Button\n\n[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://paste-button.streamlit.app/)\n\u003ca href=\"https://www.buymeacoffee.com/olucaslopes\" target=\"_blank\"\u003e\u003cimg align=\"right\" src=\"https://raw.githubusercontent.com/olucaslopes/streamlit-paste-button/main/docs/img/coffee.jpg\" alt=\"Buy Me A Coffee\" height=\"50\" width=\"180\"\u003e\u003c/a\u003e\u003cbr\u003e\n\n[![PyPI](https://img.shields.io/pypi/v/streamlit-paste-button)](https://pypi.org/project/streamlit-paste-button/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/streamlit-paste-button)](https://pypi.org/project/streamlit-paste-button/)\n![GitHub](https://img.shields.io/github/license/olucaslopes/streamlit-paste-button)\n\n![Browser Support](https://img.shields.io/badge/Browser%20Support-Chrome%20%7C%20Safari%20%7C%20Edge-green)\n![Unsupported Browsers](https://img.shields.io/badge/Unsupported%20Browsers-Firefox%20%7C%20Mobile%20Browsers-red)\n\n\nStreamlit component that allows you to paste images from your clipboard into your app with a button click.\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/olucaslopes/streamlit-paste-button/main/docs/img/demo.gif\"\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n## Installation instructions \n\n```sh\npip install streamlit-paste-button\n```\n\n## Browser support\n- The browser must support the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).\n- Secure contexts (HTTPS) are required for clipboard access in most browsers. \n\n\n## API Reference\n\n### `paste_image_button`\n\nCreate a button that can be used to paste an image from the clipboard.\n\n```\nstreamlit_paste_button.paste_image_button(\n        label: str,\n        text_color: Optional[str] = \"#ffffff\",\n        background_color: Optional[str] = \"#3498db\",\n        hover_background_color: Optional[str] = \"#2980b9\",\n        key: Optional[str] = 'paste_button',\n        errors: Optional[str] = 'ignore'\n) -\u003e PasteResult\n```\n\n- `label` : str, required\n    - The text to display on the button.\n- `text_color` : str, optional\n    - The color of the text on the button.\n    - Default: `#ffffff`\n- `background_color` : str, optional\n    - The background color of the button.\n    - Default: `#3498db`\n- `hover_background_color` : str, optional\n    - The background color of the button when the mouse is hovering over it.\n    - Default: `#2980b9`\n- `key` : str, optional\n    - An optional string to use as the unique key for the widget.\n    - Default: `paste_button`\n- `errors` : str, optional\n    - Determines how errors are handled.\n    - Default: `ignore`\n    - Possible values:\n        - `ignore` : Ignores errors.\n        - `raise` : Display errors as `st.error` messages.\n\n### `PasteResult`\n\nThe result of a paste operation.\n\n#### Attributes\n- `image_data` : PIL.Image.Image or None\n    - The image data that was pasted.\n    - If no image was pasted, this will be `None`.\n\n\n\n## Usage Examples\n\n### Basic Example\n\nCreate a paste button that displays the pasted image when clicked.\n\n```python\nimport streamlit as st\nfrom streamlit_paste_button import paste_image_button as pbutton\n\npaste_result = pbutton(\"📋 Paste an image\")\n\nif paste_result.image_data is not None:\n    st.write('Pasted image:')\n    st.image(paste_result.image_data)\n```\n\n### Customizing the button\n\nCreate a paste button with a custom label and colors.\n\n```python\nfrom streamlit_paste_button import paste_image_button as pbutton\n\npaste_result = pbutton(\n    label=\"📋 Paste an image\",\n    text_color=\"#ffffff\",\n    background_color=\"#FF0000\",\n    hover_background_color=\"#380909\",\n)\n```\n\n### Handling errors\n\nCreate a paste button that displays errors as `st.error` messages.\n\n```python\nfrom streamlit_paste_button import paste_image_button as pbutton\n\npaste_result = pbutton(\n    label=\"📋 Paste an image\",\n    errors=\"raise\",\n)\n```\n\n### Converting the PasteResult\n\nPasteResult is a PIL.Image.Image object. It can be manipulated as such.\n\n```python\nfrom streamlit_paste_button import paste_image_button as pbutton\nimport io\nimport base64\nimport numpy as np\n\npaste_result = pbutton(\"📋 Paste an image\")\n\nif paste_result.image_data is not None:\n    # Convert to bytes\n    img_bytes = io.BytesIO()\n    paste_result.image_data.save(img_bytes, format='PNG')\n    img_bytes = img_bytes.getvalue() # Image as bytes\n\n    # Convert to base64\n    img_b64 =  base64.b64encode(img_bytes).decode('utf-8') # Image as base64\n\n    # Convert to numpy array\n    img_np = np.array(paste_result.image_data) # Image as numpy array\n```","funding_links":["https://www.buymeacoffee.com/olucaslopes"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folucaslopes%2Fstreamlit-paste-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folucaslopes%2Fstreamlit-paste-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folucaslopes%2Fstreamlit-paste-button/lists"}