{"id":13484152,"url":"https://github.com/westonplatter/phashion","last_synced_at":"2025-05-14T19:08:20.280Z","repository":{"id":915848,"uuid":"677526","full_name":"westonplatter/phashion","owner":"westonplatter","description":"Ruby wrapper around pHash, the perceptual hash library for detecting duplicate multimedia files","archived":false,"fork":false,"pushed_at":"2024-06-16T12:31:31.000Z","size":9246,"stargazers_count":704,"open_issues_count":26,"forks_count":127,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-14T19:08:17.051Z","etag":null,"topics":["duplicate-multimedia-files","image-analysis","phash","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/westonplatter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2010-05-20T17:49:55.000Z","updated_at":"2025-04-17T14:19:33.000Z","dependencies_parsed_at":"2024-10-30T17:41:52.377Z","dependency_job_id":null,"html_url":"https://github.com/westonplatter/phashion","commit_stats":{"total_commits":97,"total_committers":19,"mean_commits":5.105263157894737,"dds":0.6082474226804124,"last_synced_commit":"6a316ea715d6db8f8ffb829c09609a7578ea2c9e"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonplatter%2Fphashion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonplatter%2Fphashion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonplatter%2Fphashion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonplatter%2Fphashion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/westonplatter","download_url":"https://codeload.github.com/westonplatter/phashion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"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":["duplicate-multimedia-files","image-analysis","phash","ruby"],"created_at":"2024-07-31T17:01:20.005Z","updated_at":"2025-05-14T19:08:18.781Z","avatar_url":"https://github.com/westonplatter.png","language":"Ruby","funding_links":[],"categories":["Ruby","Image Processing","Applications of machine learning"],"sub_categories":["Vector search"],"readme":"Phashion\n========\n[![Build Status](https://travis-ci.org/westonplatter/phashion.svg?branch=tests-travisci)](https://travis-ci.org/westonplatter/phashion)\n\nPhashion is a Ruby wrapper around the [pHash library](http://phash.org/), \"perceptual hash\", which detects duplicate and near-duplicate multimedia files (e.g. images, audio, video, though Phashion currently only supports images.). \"Near-duplicates\" are images that come from the same source and show essentially the same thing, but may have differences in such features as dimensions, bytesizes, lossy-compression artifacts, and color levels.\n\n[See an overview of Phashion on Mike's blog](http://www.mikeperham.com/2010/05/21/detecting-duplicate-images-with-phashion/).\n\nInstallation\n------------\n\nYou install it just like any other Ruby gem:\n\n    gem install phashion\n\nPhashion is somewhat involved to install as it has a few dependencies. Phashion\nwraps these dependencies into a custom tarball that is built locally just\nfor this gem so you don't have to do anything special. Look in the\n`ext/phashion_ext` folder for more details.\n\n\n### Compatibility\nBecause of this complexity, it is possible the gem install will fail on your\nplatform. Phashion has been tested on:\n\n* Mac OSX 10.6\n* Mac OSX 10.9\n* Ubuntu 8.04\n* Ubuntu 12.04\n\nPlease open a [GitHub issue](https://github.com/westonplatter/phashion/issues/) if you have installation problems.\n\n### Prerequisites\n\nLinux  \n- libjpeg-dev\n- libpng-dev\n\nMac\n- [imagemagick](http://www.imagemagick.org/)\n- libjpeg (Hombrew, `brew install libjpeg`; Macports, `port install jpeg`)\n- libpng (Hombrew, `brew install libpng`; Macports, `port install libpng`)\n\n\n#### Common Errors\n- `ld: library not found for -ljpeg` \u0026ndash; Did you install `libjpeg`?\n- `... sh: convert: command not found; sh: gm: command not found` \u0026ndash; Did you install [imagemagick](http://www.imagemagick.org/)?\n- `... checking for sqlite3ext.h... *** extconf.rb failed *** ...` \u0026ndash; Did you install `libpng-dev` and/or `libjpeg-dev`?\n\n\nUsage\n-----\n\n### Testing if one image is a duplicate of another\n\n```ruby\nrequire 'phashion'\nimg1 = Phashion::Image.new(filename1)\nimg2 = Phashion::Image.new(filename2)\nimg1.duplicate?(img2)\n# --\u003e true\n```\nOptionally, you can set the minimum Hamming distance in the second argument, an options Hash:\n```ruby\nimg1.duplicate?(img2, :threshold =\u003e 5)\n# --\u003e true\n\nimg1.duplicate?(img2, :threshold =\u003e 0)  \n# --\u003e false\n```\n\n### Finding the Hamming distance between two images\n\n```ruby\nrequire 'phashion'\nimg1 = Phashion::Image.new(filename1)\nimg2 = Phashion::Image.new(filename2)\nimg1.distance_from(img2)  \n# --\u003e 6\n```\n\n### Threshold for dupe-detection\n\nCurrently, the maximum Hamming distance between two duplicate images is set at 15. As per [mperham's explanation](http://www.mikeperham.com/2010/05/21/detecting-duplicate-images-with-phashion/):\n\n\u003e A “perceptual hash”is a 64-bit value based on the discrete cosine transform of the image’s frequency spectrum data. Similar images will have hashes that are close in terms of Hamming distance. That is, a binary hash value of 1000 is closer to 0000 than 0011 because it only has one bit different whereas the latter value has two bits different. The duplicate threshold defines how many bits must be different between two hashes for the two associated images to be considered different images. Our testing showed that 15 bits is a good value to start with, it detected all duplicates with a minimum of false positives.\n\nAs a reference point, here are the Hamming distances in these test comparisons using [/test/jpg/Broccoli_Super_Food.jpg](https://github.com/westonplatter/phashion/blob/master/test/jpg/Broccoli_Super_Food.jpg) as the source image:\n\n\n| Variation                                            | Hamming distance  \n| ---------------------------------------------------- | ----------------:\n| JPG to PNG                                           | 0\n| Lossy JPG (Photoshop Save for Web quality = 20)      | 0                 \n| Thumbnail (from 500px to 100px)                      | 2\n| Color correction (saturation +20 w auto-correct)     | 2          \n| Black and white                                      | 2\n| Extraneous whitespace cropped (500x349 to 466x312)   | 12\n| A sloppy rotation of 5 degrees clockwise             | 14\n| Horizontally-flipped                                 | 32\n\n\n\n\n\nGem uses customized pHash 0.9.6\n-------------------------------\n\nIn order to detech duplicate alpha PNGs, the gem uses a custom version of pHash\n0.9.6. The customization is limited to only these changes,\n[westonplatter/phash@ff255d2](https://github.com/westonplatter/phash/commit/ff255d2d3f93c841b98923ecbde997027f21ae36).\nThe gem will be moving back to the pHash master branch once it supports\ndetection of alpha PNG file types.\n\n\nTesting\n-------\n\n#### To run the test suite:\n\n    $ cd phashion\n    $ bundle install\n    $ rake compile\n    $ rake test\n\n\nAuthor\n======\n\nMike Perham,\nhttp://mikeperham.com,\nhttp://twitter.com/mperham,\nmperham AT gmail.com\n\nCopyright\n---------\n\nCopyright (c) 2010-2014 Mike Perham. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestonplatter%2Fphashion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwestonplatter%2Fphashion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestonplatter%2Fphashion/lists"}