{"id":49453575,"url":"https://github.com/ben-eb/postcss-resemble-image","last_synced_at":"2026-05-16T16:01:42.204Z","repository":{"id":46168570,"uuid":"71882686","full_name":"ben-eb/postcss-resemble-image","owner":"ben-eb","description":"Provide a gradient fallback for an image that loosely resembles the original.","archived":true,"fork":false,"pushed_at":"2017-01-18T12:38:53.000Z","size":1505,"stargazers_count":432,"open_issues_count":2,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-07T12:54:37.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ben-eb.github.io/postcss-resemble-image/","language":"JavaScript","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/ben-eb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-25T09:46:34.000Z","updated_at":"2025-03-28T02:48:47.000Z","dependencies_parsed_at":"2022-09-13T08:00:28.375Z","dependency_job_id":null,"html_url":"https://github.com/ben-eb/postcss-resemble-image","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ben-eb/postcss-resemble-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-eb%2Fpostcss-resemble-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-eb%2Fpostcss-resemble-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-eb%2Fpostcss-resemble-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-eb%2Fpostcss-resemble-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ben-eb","download_url":"https://codeload.github.com/ben-eb/postcss-resemble-image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-eb%2Fpostcss-resemble-image/sbom","scorecard":{"id":231211,"data":{"date":"2025-08-11","repo":{"name":"github.com/ben-eb/postcss-resemble-image","commit":"9aa70fa9750d964db317a817ff5e5b77b769e6ea"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 2/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-MIT:0","Info: FSF or OSI recognized license: MIT License: LICENSE-MIT:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T04:54:18.376Z","repository_id":46168570,"created_at":"2025-08-17T04:54:18.376Z","updated_at":"2025-08-17T04:54:18.376Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33109461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-04-30T04:01:03.700Z","updated_at":"2026-05-16T16:01:42.198Z","avatar_url":"https://github.com/ben-eb.png","language":"JavaScript","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# [postcss][postcss]-resemble-image [![Build Status](https://travis-ci.org/ben-eb/postcss-resemble-image.svg?branch=master)][ci] [![Build status](https://ci.appveyor.com/api/projects/status/396xfduj47prxklq?svg=true)](https://ci.appveyor.com/project/ben-eb/postcss-resemble-image) [![NPM version](https://badge.fury.io/js/postcss-resemble-image.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-resemble-image.svg)][deps]\n\n\u003e Provide a gradient fallback for an image that loosely resembles the original.\n\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-resemble-image) do:\n\n```\nnpm install postcss-resemble-image --save\n```\n\npostcss-resemble-image uses [Jimp] to perform the image analysis. The following\nimage formats are supported:\n\n* `BMP`\n* `JPEG`\n* `PNG`\n\n[Jimp]: https://github.com/oliver-moran/jimp\n\n\n## Example\n\nThis module will add a background gradient fallback for images, should the\nresource fail to load; the image fallback loosely resembles the original. The\nidea for this module was inspired by [Harry Roberts' article][csswizardry].\n\nEach image will be loaded relative to the CSS file; in these examples, `\"waves.jpg\"`\nis in the same directory as the CSS. Note that this module can also load images\nfrom a URL.\n\nThere are two ways to use postcss-resemble-image; the first allows you to\nautomatically render these gradients by providing a list of selectors\nto analyse for images. The second allows you to use a non-standard function,\n`resemble-image`, which takes a CSS URL as the first parameter and the\n*fidelity* as the second. You may use these interchangeably if you so wish.\n\n### Using the automatic render\n\n#### Options\n\n```js\n{\n    selectors: ['header']\n}\n```\n\n#### Input\n\n```css\nheader {\n    background: url(\"waves.jpg\");\n}\n```\n\n#### Output\n\n```css\nheader {\n    background: url(\"waves.jpg\"), linear-gradient(90deg, #353230 0%, #3c3835 25%, #3b3734 50%, #322f2c 75%);\n}\n```\n\n### Using the `resemble-image` function\n\n#### Defaults\n\n##### Input\n\n```css\nheader {\n    background: resemble-image(url(\"waves.jpg\"));\n}\n```\n\n##### Output\n\n```css\nheader {\n    background: url(\"waves.jpg\"), linear-gradient(90deg, #353230 0%, #3c3835 25%, #3b3734 50%, #322f2c 75%);\n}\n```\n\n#### Passing percentages\n\n`fidelity` is set globally, but can also be passed as the second parameter to the\n`resemble-image` function. This code will generate a colour stop for each tenth\nof the image.\n\n```css\nheader {\n    background: resemble-image(url(\"waves.jpg\"), 10%);\n}\n```\n\n#### Passing absolute lengths\n\n`fidelity` can also be set via a *pixel* value. Anything other than `%` will be\nparsed as a `px` value, including no unit; these are equivalent:\n\n```css\nheader {\n    background: resemble-image(url(\"waves.jpg\"), 10px);\n    background: resemble-image(url(\"waves.jpg\"), 10em);\n    background: resemble-image(url(\"waves.jpg\"), 10);\n}\n```\n\n\n## Screenshots\n\nOriginal image:\n\n\u003cimg width=\"1000\" src=\"https://rawgit.com/ben-eb/postcss-resemble-image/master/docs/waves.jpg\"\u003e\n\nAfter processing (using `simpleGradient`, with 25% stops):\n\n\u003cimg width=\"1000\" src=\"https://rawgit.com/ben-eb/postcss-resemble-image/master/docs/simple.png\"\u003e\n\nAfter processing (using `complexGradient`, with 5% stops):\n\n\u003cimg width=\"1000\" src=\"https://rawgit.com/ben-eb/postcss-resemble-image/master/docs/complex.png\"\u003e\n\nImage credit: https://unsplash.com/?photo=9EM7s13H2I0\n\n## API\n\n### `resembleImage([options])`\n\nNote that postcss-resemble-image is an *asynchronous* processor. It cannot be\nused like this:\n\n```js\nimport postcss from 'postcss';\nimport resembleImage from 'postcss-resemble-image';\n\nconst result = postcss([ resembleImage() ]).process(css).css;\nconsole.log(result);\n```\n\nInstead make sure your PostCSS runner uses the asynchronous API:\n\n```js\nimport postcss from 'postcss';\nimport resembleImage from 'postcss-resemble-image';\n\npostcss([ resembleImage() ]).process(css).then((result) =\u003e {\n    console.log(result.css);\n});\n```\n\npostcss-resemble-image is designed to be used with `import` \u0026 `export`. When\nusing `require`, make sure that you load the main module by doing:\n\n```js\nconst resembleImage = require('postcss-resemble-image').default;\n```\n\n#### options\n\n##### fidelity\n\nType: `number|string`  \nDefault: `25%`  \n\nThe `fidelity` option controls how many colour stops will be generated for the\nlinear gradient fallback. By default, it will be split into quarters. Setting\nthis to anything other than `%` will be parsed as a `px` value, including\nno unit. Zero values are not allowed.\n\n##### generator\n\nType: `function`  \nDefault: `simpleGradient`  \n\nThe `generator` option controls the rendering of the gradient function; by\ndefault it is set to `simpleGradient` which will smoothly transition between\nthe gradient stops. The `complexGradient` function hard transitions between each\ncolour, for a striped effect. To use this instead you may import the function\nfrom the module, like so:\n\n```js\nimport postcss from 'postcss';\nimport resembleImage, {complexGradient} from 'postcss-resemble-image';\n\npostcss([ resembleImage({generator: complexGradient}) ]).process(css).then((result) =\u003e {\n    console.log(result.css);\n});\n```\n\n##### selectors\n\nType: `array`  \nDefault: `[]`  \n\nThe `selectors` array controls which selectors postcss-resemble-image should\nanalyse for URLs to provide gradients for. The module tests using strict\nequality; if you are checking a selector which contains more than one simple\nselector only one of these needs to be specified. For example:\n\n```js\nimport postcss from 'postcss';\nimport resembleImage from 'postcss-resemble-image';\n\nconst css = `\nheader, footer {\n    background: url(\"waves.jpg\");\n}\n`;\n\npostcss([ resembleImage({selectors: ['footer']}) ]).process(css).then((result) =\u003e {\n    console.log(result.css);\n    // =\u003e header, footer {\n    //        background: url(\"waves.jpg\"), linear-gradient(90deg, #353230 0%, #3c3835 25%, #3b3734 50%, #322f2c 75%);\n    //    }\n});\n```\n\nNote that this option isn't required when using the `resemble-image` function.\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n| [\u003cimg src=\"https://avatars.githubusercontent.com/u/1282980?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eBen Briggs\u003c/sub\u003e](http://beneb.info)\u003cbr /\u003e[💻](https://github.com/ben-eb/postcss-resemble-image/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-resemble-image/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-resemble-image/commits?author=ben-eb) | [\u003cimg src=\"https://avatars.githubusercontent.com/u/2143782?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eManuel Wieser\u003c/sub\u003e](https://manu.ninja)\u003cbr /\u003e[💻](https://github.com/ben-eb/postcss-resemble-image/commits?author=Lorti) [⚠️](https://github.com/ben-eb/postcss-resemble-image/commits?author=Lorti) | [\u003cimg src=\"https://avatars.githubusercontent.com/u/5153378?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eSteven Sinatra\u003c/sub\u003e](http://diagramatics.me)\u003cbr /\u003e[💻](https://github.com/ben-eb/postcss-resemble-image/commits?author=diagramatics) [⚠️](https://github.com/ben-eb/postcss-resemble-image/commits?author=diagramatics) |\n| :---: | :---: | :---: |\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors] specification. Contributions of\nany kind welcome!\n\n\n## Resources\n\n* [Harry Roberts' original article][csswizardry].\n* [Manuel Wieser's resemble image blog post](https://manu.ninja/thoughts-on-linear-gradients-that-resemble-images).\n\n[csswizardry]: http://csswizardry.com/2016/10/improving-perceived-performance-with-multiple-background-images/\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n\n[all-contributors]: https://github.com/kentcdodds/all-contributors\n[ci]:      https://travis-ci.org/ben-eb/postcss-resemble-image\n[deps]:    https://gemnasium.com/ben-eb/postcss-resemble-image\n[npm]:     http://badge.fury.io/js/postcss-resemble-image\n[postcss]: https://github.com/postcss/postcss\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-eb%2Fpostcss-resemble-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fben-eb%2Fpostcss-resemble-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-eb%2Fpostcss-resemble-image/lists"}