{"id":28188413,"url":"https://github.com/pwlmc/imghash","last_synced_at":"2026-04-25T09:05:06.857Z","repository":{"id":3988545,"uuid":"51590968","full_name":"pwlmc/imghash","owner":"pwlmc","description":"Perceptual image hashing for Node.js","archived":false,"fork":false,"pushed_at":"2026-04-25T07:32:07.000Z","size":979,"stargazers_count":195,"open_issues_count":6,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-04-25T08:36:04.985Z","etag":null,"topics":["computer-vision","image-processing","imghash","webscraping"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/pwlmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-02-12T14:03:21.000Z","updated_at":"2026-04-25T07:29:12.000Z","dependencies_parsed_at":"2025-07-19T12:24:19.900Z","dependency_job_id":"571897f1-ee46-471c-a935-5dd3cd0a7473","html_url":"https://github.com/pwlmc/imghash","commit_stats":null,"previous_names":["pwlmc/imghash"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/pwlmc/imghash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwlmc%2Fimghash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwlmc%2Fimghash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwlmc%2Fimghash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwlmc%2Fimghash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwlmc","download_url":"https://codeload.github.com/pwlmc/imghash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwlmc%2Fimghash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32256221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["computer-vision","image-processing","imghash","webscraping"],"created_at":"2025-05-16T08:33:38.848Z","updated_at":"2026-04-25T09:05:06.851Z","avatar_url":"https://github.com/pwlmc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imghash ![Version](https://img.shields.io/npm/v/imghash) ![License](https://img.shields.io/npm/l/imghash)\n\nPromise-based image perceptual hash calculation for Node.js\n\n## Installation\n\n```\nnpm install imghash\n```\n\n:information_source: You can find the command-line interface [here](https://github.com/pwlmaciejewski/imghash-cli).\n\n## Basic usage\n\n```js\nconst imghash = require(\"imghash\");\n\nconst hash1 = await imghash.hash(\"./path/to/file\");\nconsole.log(hash1); // \"f884c4d8d1193c07\"\n\n// Custom hex length and result in binary\nconst hash2 = await imghash.hash(\"./path/to/file\", 4, \"binary\");\nconsole.log(hash2); // \"1000100010000010\"\n```\n\n## Finding similar images\n\nTo measure similarity between images you can use [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) or [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance).\n\nThe following example uses the latter one:\n\n```js\nconst imghash = require(\"imghash\");\nconst leven = require(\"leven\");\n\nconst hash1 = await imghash.hash(\"./img1\");\nconst hash2 = await imghash.hash(\"./img2\");\n\nconst distance = leven(hash1, hash2);\nconsole.log(`Distance between images is: ${distance}`);\nif (distance \u003c= 12) {\n  console.log(\"Images are similar\");\n} else {\n  console.log(\"Images are NOT similar\");\n}\n```\n\n## API\n\n##### `.hash(filepath[, bits][, format])`\n\nReturns: ES6 `Promise`, resolved returns hash string in specified format and length (eg. `f884c4d8d1193c07`)\n\nParameters:\n\n- `filepath` - path to the image (supported formats are `png` and `jpeg`) or `Buffer`\n- `bits` (optional) - hash length [default: `8`]\n- `format` (optional) - output format [default: `hex`]\n\n---\n\n##### `.hashRaw(data, bits)`\n\nReturns: hex hash\n\nParameters:\n\n- `data` - image data descriptor in form `{ width: [width], height: [height], data: [decoded image pixels] }`\n- `bits` - hash length\n\n---\n\n##### `.hexToBinary(s)`\n\nReturns: hex string, eg. `f884c4d8d1193c07`.\n\nParameters:\n\n- `s` - binary hash string eg. `1000100010000010`\n\n---\n\n##### `.binaryToHex(s)`\n\nReturns: hex string, eg. `1000100010000010`.\n\nParameters:\n\n- `s` - hex hash string eg. `f884c4d8d1193c07`\n\n## Further reading\n\n`imghash` takes advantage of block mean value based hashing method:\n\n- [http://stackoverflow.com/questions/14377854/block-mean-value-hashing-method](http://stackoverflow.com/questions/14377854/block-mean-value-hashing-method)\n- [http://commonsmachinery.se/2014/09/digital-image-matching-part-1-hashing/](http://commonsmachinery.se/2014/09/digital-image-matching-part-1-hashing/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwlmc%2Fimghash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwlmc%2Fimghash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwlmc%2Fimghash/lists"}