Skip to content

Performs a Photoshop/GIMP curve adjustment on a RGB color

License

Notifications You must be signed in to change notification settings

jzecca/color-curve-adjust

Repository files navigation

color-curve-adjust

Build Status Coverage

Performs a Photoshop/GIMP curve adjustment on a RGB color

Based on CSPL.js. Read more about the algorithm here.

Install

$ npm install color-curve-adjust

Usage

  • Edit your curve in Photoshop

    Photoshop curve

  • Create an array of each point of the curve

    const curve = [
        { x: 0, y: 85 },
        { x: 50, y: 120 },
        { x: 140, y: 200 },
        { x: 190, y: 225 },
        { x: 255, y: 255 },
    ];
  • Import the module and call it with a color and your array

    import curveAdjust from 'color-curve-adjust';
    
    curveAdjust('#5a2149', curve);
    //=> '#9d6b8d'
    
    curveAdjust('#5a2149', curve, 'r');   // adjust only the red channel
    //=> '#9d2149'
    
    curveAdjust('#5a2149', curve, 'gb');  // adjust only green & blue channels
    //=> '#5a6b8d'

License

MIT © Jérôme Zecca