Brightnes
his method asynchronously changes the brightness of the specified image element by applying a brightness adjustment factor.
Syntax
changeBrightness(image, factor)
Parameters
-
image :
HTMLImageElement
The image element to change the brightness of. -
factor :
number
The brightness adjustment factor (-100 to 100):- factor > 0: the image luminance gets increased by the factor.
- factor < 0: the image luminance gets decreased by the factor.
- factor = 0: the image does not change.
Return
- Promise :
Promise<HTMLImageElement>
A promise that resolves with the image element with adjusted brightness.
Throws
Error
Thrown if the specified brightness factor is outside the valid range.
Examples
const editpix = new EditPix();
// image url
const url = "images/img.jpg";
// crate image
var image = new Image();
image.src = url;
//waiting image load
image.onload = () => {
//change brightness of image
editpix.changeBrightness(image, -90)
.then(resultImage => {
// render modified image
document.body.appendChild(resultImage);
})
.catch(error => { console.log(error) })
}