{"id":20273581,"url":"https://github.com/astropilot/thumbhash-python","last_synced_at":"2025-04-11T04:43:10.429Z","repository":{"id":150967265,"uuid":"618502482","full_name":"Astropilot/thumbhash-python","owner":"Astropilot","description":"A Python implementation of the Thumbhash image placeholder generation algorithm.","archived":false,"fork":false,"pushed_at":"2024-03-12T00:03:20.000Z","size":87,"stargazers_count":14,"open_issues_count":11,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T04:43:05.102Z","etag":null,"topics":["image-hash","image-processing","python","python-types","python3","thumbhash"],"latest_commit_sha":null,"homepage":"","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/Astropilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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-03-24T15:54:34.000Z","updated_at":"2025-03-10T14:50:04.000Z","dependencies_parsed_at":"2024-11-19T21:47:02.257Z","dependency_job_id":null,"html_url":"https://github.com/Astropilot/thumbhash-python","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astropilot%2Fthumbhash-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astropilot%2Fthumbhash-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astropilot%2Fthumbhash-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astropilot%2Fthumbhash-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astropilot","download_url":"https://codeload.github.com/Astropilot/thumbhash-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345281,"owners_count":21088242,"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":["image-hash","image-processing","python","python-types","python3","thumbhash"],"created_at":"2024-11-14T12:49:32.948Z","updated_at":"2025-04-11T04:43:10.411Z","avatar_url":"https://github.com/Astropilot.png","language":"Python","readme":"\u003ch1 align=\"center\"\u003e\n    \u003cbr\u003e\n    ThumbHash for Python\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/Astropilot/thumbhash-python/actions?query=workflow%3ATest+event%3Apush+branch%3Amain\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://github.com/Astropilot/thumbhash-python/workflows/Test/badge.svg?event=push\u0026branch=main\" alt=\"Test\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/Astropilot/thumbhash-python\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://coverage-badge.samuelcolvin.workers.dev/Astropilot/thumbhash-python.svg\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/thumbhash-python\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/thumbhash-python?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/thumbhash-python\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/thumbhash-python.svg?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/Astropilot/thumbhash-python/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/Astropilot/thumbhash-python\" alt=\"MIT License\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n# Introduction\n\nThe thumbhash library implements the [Thumbhash](https://evanw.github.io/thumbhash/) image placeholder generation algorithm invented by [Evan Wallace](https://madebyevan.com/) in Python.\n\nA full explanation and interactive example of the algorithm can be found at https://github.com/evanw/thumbhash\n\n# Installation\n\nYou need Python 3.7+.\n\n```console\n$ pip install thumbhash-python\n```\n\n# Usage\n\nCreate thumbhash from image file:\n```py\nfrom thumbhash import image_to_thumbhash\n\nwith open('image.jpg', 'rb') as image_file:\n    hash = image_to_thumbhash(image_file)\n```\n\nYou can also pass file name as parameter to the function:\n```py\nfrom thumbhash import image_to_thumbhash\n\nhash = image_to_thumbhash('image.jpg')\n```\nThese functions use the Pillow library to read the image.\n\nIf you want to directly convert a rgba array to a thumbhash, you can use the low-level function:\n```py\nfrom thumbhash.encode import rgba_to_thumbhash\n\nrgba_to_thumbhash(w: int, h: int, rgba: Sequence[int]) -\u003e bytes\n```\n\nTo decode a thumbhash into an image:\n```py\nfrom thumbhash import thumbhash_to_image\n\nimage = thumbhash_to_image(\"[THUMBHASH]\", base_size=128)\n\nimage.show()\n\nimage.save('path/to/file.png')\n```\n\nAlternatively you can use the following function to deal directly with the pixels array (without relying on Pillow):\n```py\nfrom thumbhash.decode import thumbhash_to_rgba\n\ndef thumbhash_to_rgba(\n    hash: bytes, base_size: int = 32, saturation_boost: float = 1.25\n) -\u003e Tuple[int, int, List[int]]\n```\n\n## CLI\n\nYou can also use the CLI mode to encode or decode directly via your shell.\n\n**Usage**:\n\n```console\n$ thumbhash [OPTIONS] COMMAND [ARGS]...\n```\n\n**Options**:\n\n* `--install-completion`: Install completion for the current shell.\n* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.\n* `--help`: Show this message and exit.\n\n**Commands**:\n\n* `decode`: Save thumbnail image from thumbhash\n* `encode`: Get thumbhash from image\n\n### `thumbhash decode`\n\nSave thumbnail image from thumbhash\n\n**Usage**:\n\n```console\n$ thumbhash decode [OPTIONS] IMAGE_PATH HASH\n```\n\n**Arguments**:\n\n* `IMAGE_PATH`: The path where the image created from the hash will be saved  [required]\n* `HASH`: The base64-encoded thumbhash  [required]\n\n**Options**:\n\n* `-s, --size INTEGER RANGE`: The base size of the output image  [default: 32; x\u003e=1]\n* `--saturation FLOAT`: The saturation boost factor to use  [default: 1.25]\n* `--help`: Show this message and exit.\n\n### `thumbhash encode`\n\nGet thumbhash from image\n\n**Usage**:\n\n```console\n$ thumbhash encode [OPTIONS] IMAGE_PATH\n```\n\n**Arguments**:\n\n* `IMAGE_PATH`: The path of the image to convert  [required]\n\n**Options**:\n\n* `--help`: Show this message and exit.\n\n\n## Contributing\n\nSee [Contributing documentation](./.github/CONTRIBUTING.md)\n\n## License\n\n`thumbhash-python` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastropilot%2Fthumbhash-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastropilot%2Fthumbhash-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastropilot%2Fthumbhash-python/lists"}