{"id":13577458,"url":"https://github.com/jpederson/node-colorvert","last_synced_at":"2026-01-05T08:58:37.972Z","repository":{"id":17561599,"uuid":"20364936","full_name":"jpederson/node-colorvert","owner":"jpederson","description":"A node module that provides both math-based and ICC profile-based color conversions. Aims to provide accurate conversions between CMYK, Lab, XYZ, RGB, HSL, HSV, and Hex colorspaces.","archived":false,"fork":false,"pushed_at":"2023-03-04T03:34:51.000Z","size":180,"stargazers_count":27,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-05T14:45:15.307Z","etag":null,"topics":["cmyk","color","color-conversion","colorspace","conversion","convert-colors","hex","hsl","icc-profile","javascript","lab","rgb","xyz"],"latest_commit_sha":null,"homepage":"","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/jpederson.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":"2014-05-31T20:51:53.000Z","updated_at":"2024-09-17T02:48:38.000Z","dependencies_parsed_at":"2024-11-05T15:00:48.207Z","dependency_job_id":null,"html_url":"https://github.com/jpederson/node-colorvert","commit_stats":null,"previous_names":["jpederson/colorvert"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpederson%2Fnode-colorvert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpederson%2Fnode-colorvert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpederson%2Fnode-colorvert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpederson%2Fnode-colorvert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpederson","download_url":"https://codeload.github.com/jpederson/node-colorvert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247331827,"owners_count":20921845,"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":["cmyk","color","color-conversion","colorspace","conversion","convert-colors","hex","hsl","icc-profile","javascript","lab","rgb","xyz"],"created_at":"2024-08-01T15:01:21.649Z","updated_at":"2026-01-05T08:58:37.914Z","avatar_url":"https://github.com/jpederson.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## colorvert\n\nThis node module converts colors between CMYK, Lab, XYZ, RGB, HSL, HSV, and Hex colorspaces. Colorvert uses the [transicc](https://github.com/jpederson/node-transicc) node module to provide ICC profile-based color conversions between several color spaces. If you only need conversions between ICC profiles (CMYK, Lab, XYZ, and RGB), look to that module.\n\n*For a JSON HTTP API:* Check out the [colorvert-api](https://github.com/jpederson/node-colorvert-api) node module. It uses this module and [express](https://github.com/strongloop/express) to serve HTTP endpoints that convert the input color to all other colorspaces. It's ideal for batch color conversions.\n\n*****\n\n![GitHub release](https://img.shields.io/github/release/jpederson/node-colorvert.svg?label=github) ![npm](https://img.shields.io/npm/v/colorvert.svg)\n\n*****\n\n### Installation Requirements\n\nYou must first install LittleCMS, an open source library written mostly in C for converting colors using ICC profiles. This shell script will get you there.\n\n```shell\ngit clone https://github.com/mm2/Little-CMS.git\ncd Little-CMS\n./configure \nmake \nmake check \nsudo make install\n```\n\nOnce you've installed that dependency, you're ready to install colorvert and get goin'!\n\n```shell\nnpm install colorvert --save\n```\n\n*****\n\n### Quick Examples\n\n```js\nvar cvert = require( \"colorvert\" );\n\n// CMYK, XYZ, and Lab-based conversions require\n// you to provide a callback function.\ncvert.cmyk_to_rgb( 100, 0, 0, 0, function( err, rgb ){\n\tconsole.log( rgb );\n});\n\n// RGB, HSL, HSV, and hex conversions simply \n// return values.\nvar hex = cvert.rgb_to_hex( 0, 172, 236 );\n```\n\n*****\n\n### Single Conversion\n\nIf you only need to convert from one color to another, just include that specific conversion module - it'll keep node from caching extra modules it won't need. Here's an example:\n\n```js\nvar cmyk_to_hex = require( \"colorvert/cmyk/hex\" );\n\ncmyk_to_hex( 100, 0, 0, 0, function( err, hex ){\n\tconsole.log( hex );\n});\n```\n\n*****\n\n### CMYK, Lab \u0026 XYZ Conversions\n\nThese conversions require us to use the `transicc` node module that interacts with a command line utility. As a result, we have to wait for the response before doing anything with it, so you must provide a callback when converting **to or from** any of these formats. Here's an example:\n\n```js\ncvert.cmyk_to_rgb( 100, 0, 0, 0, function( err, rgb ){\n\tconsole.log( rgb );\n});\n```\n\n*****\n\n### Math-only Conversions\n\nIf you're converting between RGB, HSL, HSV, or hex, the functions will simply return the value for you to use right away. Here's how that'll look.\n\n```js\nvar hex = cvert.rgb_to_hex( 0, 146, 210 );\nconsole.log( hex );\n```\n\n*****\n\n### Convert to ALL Other Colorspaces\n\nEach of the colorspaces includes a module that converts to all other colorspaces. As a bonus, the output will also include the hex code of the inverted color, and will suggest the most readable text color to display over the input color. Use it like so:\n\n```js\ncvert.cmyk_to_all( 100, 0, 0, 0, function( err, all ){\n\tconsole.log( all );\n\t/*\n\tOutputs:\n\t{\n\t\t\"cmyk\": {\n\t\t\t\"c\": \"100\",\n\t\t\t\"m\": \"0\",\n\t\t\t\"y\": \"0\",\n\t\t\t\"k\": \"0\"\n\t\t},\n\t\t\"lab\": {\n\t\t\t\"l\": 59,\n\t\t\t\"a\": -37,\n\t\t\t\"b\": -49\n\t\t},\n\t\t\"hex\": \"#00a0e0\",\n\t\t\"hex_inverted\": \"#ff5f1f\",\n\t\t\"hex_readable\": \"#ffffff\",\n\t\t\"hsl\": {\n\t\t\t\"h\": 197,\n\t\t\t\"s\": 100,\n\t\t\t\"l\": 43\n\t\t},\n\t\t\"hsv\": {\n\t\t\t\"h\": 197,\n\t\t\t\"s\": 100,\n\t\t\t\"v\": 87\n\t\t},\n\t\t\"rgb\": {\n\t\t\t\"r\": 0,\n\t\t\t\"g\": 160,\n\t\t\t\"b\": 224\n\t\t},\n\t\t\"xyz\": {\n\t\t\t\"x\": 52,\n\t\t\t\"y\": 71,\n\t\t\t\"z\": 197\n\t\t}\n\t}\n\t*/\n});\n```\n\n*****\n\n### Warning! :)\n\nThis module has been pretty reliable during all my tests and with everything I've thrown at it. That said, I haven't written tests for everything yet, so be sure to test it in your environment and with your input - if you find any issues, please post them on Github or submit a pull request!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpederson%2Fnode-colorvert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpederson%2Fnode-colorvert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpederson%2Fnode-colorvert/lists"}