Pixastic Docs

JavaScript Image Processing Library

Documentation: Brightness/Contrast

Description

This action allows you to adjust the brightness and contrast of the image. It takes three parameters, one for brightness, one for contrast and one for selecting “legacy” brightness mode.

If the legacy mode is selected, the brightness is adjusted the same way Photoshop did it prior to CS3, that is simply add the value to the pixel, effectively shifting the histogram. Otherwise, each pixel is multiplied with the factor (brightness_value / 150), creating an effect more like the Lighten action.

Demo

Brightness:
Legacy:
Contrast:

Example usage

var img = new Image();
img.onload = function() {
	Pixastic.process(img, "brightness", {brightness:50,contrast:0.5});
}
document.body.appendChild(img);
img.src = "myimage.jpg";

Parameters

  • brightness (int)
    The brightness value used, -150 to 150.
  • contrast (float)
    The contrast value, -1 to infinity, where a negative value decreases contrast, zero does nothing and positive values increase contrast.
  • legacy (bool)
    If true, brightness will be adjusted the same way Photoshop used to prior to CS3 (now called “Legacy” in the B&C dialog). This means the brightness value is simply added to the pixel value, in effect shifting the entire histogram left or right.

View source: brightness.js

Browser support