{"id":13447668,"url":"https://github.com/mouafa/roya","last_synced_at":"2025-03-22T01:31:10.691Z","repository":{"id":143906982,"uuid":"146938833","full_name":"mouafa/roya","owner":"mouafa","description":"🔎 Find diff between two images","archived":false,"fork":false,"pushed_at":"2019-02-21T13:58:39.000Z","size":133,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-09T03:33:58.926Z","etag":null,"topics":["diff","matching","regression"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/malal","language":"JavaScript","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/mouafa.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}},"created_at":"2018-08-31T20:19:48.000Z","updated_at":"2019-09-11T01:15:41.000Z","dependencies_parsed_at":"2023-04-25T16:19:37.802Z","dependency_job_id":null,"html_url":"https://github.com/mouafa/roya","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"6525f9ae4a4f9fdfd096ee57f6bdf39fb4e47d93"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mouafa%2Froya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mouafa%2Froya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mouafa%2Froya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mouafa%2Froya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mouafa","download_url":"https://codeload.github.com/mouafa/roya/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244508036,"owners_count":20463714,"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":["diff","matching","regression"],"created_at":"2024-07-31T05:01:23.909Z","updated_at":"2025-03-22T01:31:10.388Z","avatar_url":"https://github.com/mouafa.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"auto\" src=\"https://raw.githubusercontent.com/mouafa/roya/master/assets/cover.png\"\u003e\u003c/p\u003e\n\nRoya is a small low-level image comparison library.\n\n[![npm version](https://badge.fury.io/js/roya.svg)](https://badge.fury.io/js/roya)\n[![Coverage Status](https://coveralls.io/repos/github/mouafa/roya/badge.svg?branch=master)](https://coveralls.io/github/mouafa/roya?branch=master)\n[![Build Status](https://api.travis-ci.org/mouafa/roya.svg?branch=master)](https://travis-ci.org/mouafa/roya#)\n\nInspired by [pixelmatch](https://github.com/mapbox/pixelmatch) with more bells and whistles.\n\n## Installation\n\nusing yarn\n\n```bash\nyarn add roya\n```\n\nusing npm\n\n```bash\nnpm i -S roya\n```\n\n### API\n\n```\nroya(img1, img2, [, options])\n```\n\n`img1`, `img2` — Image data of type `Buffer` of the images to compare\n\n`options` Optional object options with the following properties:\n\n| Property       | Description                                                                                                    | Default     |\n| -------------- | -------------------------------------------------------------------------------------------------------------- | ----------- |\n| threshold      | Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive                      | 0.1         |\n| highlightFade  | Highlight color intensity will depend on the pixel ditance value                                               | true        |\n| highlightColor | The used highlight color, should be an array of [R,G,B] values                                                 | [255, 0, 0] |\n| transparent    | Whether to keep the original image ot to use a blank convas to highlight the diff                              | false       |\n| overlapse      | Whether to use the highlight color or use the changing pixel itself                                            | false       |\n| method         | Matching and diffing method to be used, should be one of the available methods, rgb, rgbTuned, yiq or yiqTuned | 'rgb'       |\n\n**P.S.** rgb method is the fastest but it might not be the best for your usecase, try the others method and pick the right one for you.\n\n### Example:\n\n| img1                            | img2                            |\n| ------------------------------- | ------------------------------- |\n| ![](testdrive/fixture/img1.png) | ![](testdrive/fixture/img2.png) |\n\n| options                                        | result                                           |\n| ---------------------------------------------- | ------------------------------------------------ |\n| `undefined`                                    | ![](testdrive/fixture/diff_default.png)          |\n| `{ threshold: 0.5 }`                           | ![](testdrive/fixture/diff_higher_threshold.png) |\n| `{ highlightColor: [255, 255, 0] }`            | ![](testdrive/fixture/diff_yellow.png)           |\n| `{ highlightFade: false }`                     | ![](testdrive/fixture/diff_solid.png)            |\n| `{ transparent: true, highlightFade: false }`  | ![](testdrive/fixture/diff_transparent.png)      |\n| `{ overlapse: true, transparent: true }`       | ![](testdrive/fixture/diff_overlapse.png)        |\n|                                                |\n| `{ method: 'rgb', highlightFade: false }`      | ![](testdrive/fixture/diff_method_rgb.png)       |\n| `{ method: 'rgbTuned', highlightFade: false }` | ![](testdrive/fixture/diff_method_rgbTuned.png)  |\n| `{ method: 'yiq', highlightFade: false }`      | ![](testdrive/fixture/diff_method_yiq.png)       |\n| `{ method: 'yiqTuned', highlightFade: false }` | ![](testdrive/fixture/diff_method_yiqTuned.png)  |\n\n## Usage\n\n```js\nconst fs = require('fs')\nconst PNG = require('pngjs').PNG\nconst roya = require('roya')\n\nvar img1 = fs\n  .createReadStream('img1.png')\n  .pipe(new PNG())\n  .on('parsed', parsed)\n\nvar img2 = fs\n  .createReadStream('img2.png')\n  .pipe(new PNG())\n  .on('parsed', parsed)\n\nlet done = 0\nfunction parsed() {\n  done++\n  if (done \u003c 2) return\n  const out = roya(img1.data, img2.data)\n\n  const diff = new PNG({ width: img1.width, height: img1.height })\n\n  diff.data = out.data\n\n  diff\n    .pack()\n    .pipe(fs.createWriteStream('diff.png'))\n    .on('finish', () =\u003e console.log('done'))\n}\n```\n\n**P.S.** image dimensions must be equal.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmouafa%2Froya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmouafa%2Froya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmouafa%2Froya/lists"}