{"id":32212101,"url":"https://github.com/mauke/image-thumbhash","last_synced_at":"2026-02-19T08:36:17.767Z","repository":{"id":320138772,"uuid":"618486097","full_name":"mauke/Image-ThumbHash","owner":"mauke","description":"A very compact representation of an image placeholder","archived":false,"fork":false,"pushed_at":"2023-03-25T07:24:17.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T06:57:53.011Z","etag":null,"topics":["image-hash","image-processing","perl"],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/Image::ThumbHash","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauke.png","metadata":{"files":{"readme":".github/README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-24T15:14:54.000Z","updated_at":"2023-03-24T18:33:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mauke/Image-ThumbHash","commit_stats":null,"previous_names":["mauke/image-thumbhash"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mauke/Image-ThumbHash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauke%2FImage-ThumbHash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauke%2FImage-ThumbHash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauke%2FImage-ThumbHash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauke%2FImage-ThumbHash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauke","download_url":"https://codeload.github.com/mauke/Image-ThumbHash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauke%2FImage-ThumbHash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280395522,"owners_count":26323517,"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","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","perl"],"created_at":"2025-10-22T06:57:53.264Z","updated_at":"2025-10-22T06:58:11.154Z","avatar_url":"https://github.com/mauke.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Coverage Status](https://coveralls.io/repos/github/mauke/Image-ThumbHash/badge.svg?branch=main)](https://coveralls.io/github/mauke/Image-ThumbHash?branch=main)\n\n# NAME\n\nImage::ThumbHash - A very compact representation of an image placeholder\n\n# SYNOPSIS\n\n```perl\nuse Image::ThumbHash qw(\n    rgba_to_thumb_hash\n    rgba_to_png\n    rgba_to_data_url\n    thumb_hash_to_rgba\n    thumb_hash_to_average_rgba\n    thumb_hash_to_approximate_aspect_ratio\n    thumb_hash_to_data_url\n);\n```\n\n# DESCRIPTION\n\nThis module implements the [ThumbHash](https://evanw.github.io/thumbhash/)\nimage placeholder generation algorithm by\n[Evan Wallace](https://madebyevan.com/).\n\nThis algorithm reduces small (thumbnail) images to an even smaller chunk of\nbytes, the \"thumb hash\". The thumb hash can then be used to recreate a lossy\napproximation of the original image.\n\nThe main use case of this algorithm is to reduce initial loading times of image\ngalleries on the web. You would either convert the thumb hash to a small\n(inline) PNG on the server and embed in your HTML, or embed the raw thumb hash\nand convert it to a PNG on the client side (using JavaScript). In either case,\nyou end up with small placeholder images that load instantly while the original\nimages can be loaded in asynchronously.\n\n# FUNCTIONS\n\nThis module exports the following functions on request.\n\n## rgba\\_to\\_thumb\\_hash\n\n```perl\nmy $thumbhash = rgba_to_thumb_hash($width, $height, $rgba);\n```\n\nEncodes an RGBA image to a thumb hash. RGB should not be premultiplied by A.\n\n`$width` is the image width; `$height` is the image height. Both are in\npixels and must be 100 or less.\n\n`$rgba` is a raw byte string containing 4 bytes for each pixel in the image,\nrepresenting the red, green, blue, and alpha channels, respectively. That is,\n`length($rgba) == $width * $height * 4`.\n\nThe return value is a byte string containing the thumb hash.\n\n## rgba\\_to\\_png\n\n```perl\nmy $png = rgba_to_png($width, $height, $rgba);\n```\n\nEncodes an RGBA image to PNG. RGB should not be premultiplied by A. The\nresulting PNG is not optimized for size or compressed in any way.\n\n`$width` is the image width; `$height` is the image height. Both are in\npixels and must be 100 or less.\n\n`$rgba` is a raw byte string containing 4 bytes for each pixel in the image,\nrepresenting the red, green, blue, and alpha channels, respectively. That is,\n`length($rgba) == $width * $height * 4`.\n\nThe return value is a byte string containing the PNG.\n\n## rgba\\_to\\_data\\_url\n\n```perl\nmy $url = rgba_to_data_url($width, $height, $rgba);\n```\n\nEncodes an RGBA image to a PNG data URL. RGB should not be premultiplied by A.\n\n`$width` is the image width; `$height` is the image height. Both are in\npixels and must be 100 or less.\n\n`$rgba` is a raw byte string containing 4 bytes for each pixel in the image,\nrepresenting the red, green, blue, and alpha channels, respectively. That is,\n`length($rgba) == $width * $height * 4`.\n\nThe return value is a string containing a `data:` URL.\n\nThis is equivalent to:\n\n```perl\nuse MIME::Base64 qw(encode_base64);\nmy $url = 'data:image/png;base64,' . encode_base64(rgba_to_png($width, $height, $rgba), \"\");\n```\n\n## thumb\\_hash\\_to\\_rgba\n\n```perl\nmy ($width, $height, $rgba) = thumb_hash_to_rgba($thumbhash);\n```\n\nDecodes a thumb hash to an RGBA image. RGB is not premultiplied by A.\n\nThe return value is a list containing the image width, height, and pixels as a\nbyte string in RGBA format.\n\n## thumb\\_hash\\_to\\_average\\_rgba\n\n```perl\nmy ($red, $green, $blue, $alpha) = thumb_hash_to_average_rgba($thumbhash);\n```\n\nExtracts the average color from a thumb hash. RGB is not premultiplied by A.\n\nThe return value is a list containing the numeric RGBA values for the average\ncolor, in the range from 0 to 1.\n\n## thumb\\_hash\\_to\\_approximate\\_aspect\\_ratio\n\n```perl\nmy $aspect_ratio = thumb_hash_to_approximate_aspect_ratio($thumbhash);\n```\n\nExtracts and returns the approximate aspect ratio of the original image, i.e.\nwidth/height.\n\n## thumb\\_hash\\_to\\_data\\_url\n\n```perl\nmy $url = thumb_hash_to_data_url($thumbhash);\n```\n\nDecodes a thumb hash to a PNG data URL.\n\nThis is equivalent to:\n\n```perl\nmy $url = rgba_to_data_url(thumb_hash_to_rgba($thumbhash));\n```\n\n# AUTHOR\n\nLukas Mai, `\u003clmai at web.de\u003e`\n\n# COPYRIGHT \u0026 LICENSE\n\nThe original concept and code are:\n\n\u003e Copyright (c) 2023 Evan Wallace\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy of\n\u003e this software and associated documentation files (the \"Software\"), to deal in\n\u003e the Software without restriction, including without limitation the rights to\n\u003e use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\u003e of the Software, and to permit persons to whom the Software is furnished to do\n\u003e so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in all\n\u003e copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003e IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003e FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003e AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003e LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003e OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\u003e SOFTWARE.\n\nSee [https://github.com/evanw/thumbhash](https://github.com/evanw/thumbhash).\n\nThe Perl implementation, documentation, and tests are:\n\nCopyright 2023 Lukas Mai.\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of either: the GNU General Public License as published\nby the Free Software Foundation; or the Artistic License.\n\nSee [https://dev.perl.org/licenses/](https://dev.perl.org/licenses/) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauke%2Fimage-thumbhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauke%2Fimage-thumbhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauke%2Fimage-thumbhash/lists"}