Skip to main content

Temperature

This method asynchronously changes the temperature of the specified image element by applying a temperature adjustment factor.

Syntax

changeTemperature(image, factor)

Parameters

  • image : HTMLImageElement
    The image element to change the temperature of.

  • factor : number
    The temperature adjustment factor (-100 to 100):

    • factor > 0: the image towards warmer tones.
    • factor < 0: the image towards cooler tones.
    • factor = 0: the image does not change.

Return

  • Promise : Promise<HTMLImageElement>
    A promise that resolves with the image element with adjusted temperature.

Throws

  • Error
    Thrown if the specified temperature factor is outside the valid range.

Examples

const editpix = new EditPix();

// image url
const url = "images/img.jpg";

// create image
var image = new Image();
image.src = url;

// waiting image load
image.onload = () => {
// change image temperature
editpix.adjustTemperature(image, 20)
.then(resultImage => {
// render modified image
document.body.appendChild(resultImage);
})
.catch(error => { console.log(error) })
}