Finetuning in the EJ2 TypeScript Image Editor control

25 Mar 202511 minutes to read

Fine-tuning involves making precise adjustments to the settings of an image filter in order to achieve a specific desired effect. It provides control over the intensity and specific aspects of the filter’s impact on the image. For example, fine-tuning allows you to modify parameters like brightness, saturation, or other relevant properties to fine-tune the level or quality of the filter’s effect. This level of control enables you to achieve the exact look or outcome you want for your image.

Adjust the brightness, contrast, and saturation

The finetuneImage method is designed to facilitate fine-tuning operations on an image. It accepts two parameters: the first parameter is ImageFinetuneOption which determines the type of fine-tuning to be applied (brightness, contrast, and saturation), and the second parameter represents the fine-tuning value, indicating the degree or intensity of the adjustment. This method allows for convenient adjustment of brightness, contrast, and saturation by specifying the desired type and corresponding value.

The finetuneImage method is used to perform brightness, contrast, and saturation fine-tuning by specifying this type as a first parameter and specifying the fine-tuning value as the second parameter of the method.

Here is an example of brightness, contrast, and saturation fine-tuning using the finetuneImage method.

  • finetuneOption - Specifies the finetune options to be performed in the image.

  • value - Specifies the value for finetuning the image.

In the following example, you can using the finetuneImage method in the button click event.

import { ImageEditor, ImageFinetuneOption } from '@syncfusion/ej2-image-editor';
import { Browser } from '@syncfusion/ej2-base';

//Image Editor items definition

let imageEditorObj: ImageEditor = new ImageEditor({
    width: '550px',
    height: '330px',
    toolbar: [],
    created: () => {
        if (Browser.isDevice) {
            imageEditorObj.open('bee-eater.png');
        } else {
            imageEditorObj.open('bee-eater.png');
        }
    }
});
imageEditorObj.appendTo('#imageeditor');

(document.getElementById('brightnessClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Brightness, 10);
};
(document.getElementById('contrastClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Contrast, 30);
};
(document.getElementById('saturationClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Saturation, 100);
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <meta name="description" content="Essential JS 2" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-lists/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-image-editor/styles/material.css" rel="stylesheet" />

    <!--style reference from app-->
    <link href="styles.css" rel="stylesheet" />

    <!--system js reference and configuration-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <div class="control-section">
            <div id="imageeditor" class="row">
            </div>
            <div>
                <button id='brightnessClick' class='e-btn e-primary'>Brightness</button>
                <button id='contrastClick' class='e-btn e-primary'>Contrast</button>
                <button id='saturationClick' class='e-btn e-primary'>Saturation</button>
            </div>
        </div>
    </div>
</body>

</html>

Adjust the hue, exposure, blur, and opacity

The finetuneImage method is designed to facilitate fine-tuning operations on an image. It accepts two parameters: the first parameter is ImageFinetuneOption which determines the type of fine-tuning to be applied (hue, exposure, blur, and opacity), and the second parameter represents the fine-tuning value, indicating the degree or intensity of the adjustment. This method allows for convenient adjustment of hue, exposure, blur, and opacity by specifying the desired type and corresponding value.

Here is an example of hue, exposure, blur, and opacity fine-tuning using the finetuneImage method.

  • finetuneOption - Specifies the finetune options to be performed in the image.

  • value - Specifies the value for finetuning the image.

In the following example, you can using the finetuneImage method in the button click event.

import { ImageEditor, ImageFinetuneOption } from '@syncfusion/ej2-image-editor';
import { Browser } from '@syncfusion/ej2-base';

//Image Editor items definition
let imageEditorObj: ImageEditor = new ImageEditor({
    width: '550px',
    height: '330px',
    toolbar: [],
    created: () => {
        if (Browser.isDevice) {
            imageEditorObj.open('bee-eater.png');
        } else {
            imageEditorObj.open('bee-eater.png');
        }
    }
});
imageEditorObj.appendTo('#imageeditor');

(document.getElementById('hueClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Hue, 20);
};
(document.getElementById('exposureClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Exposure, 20);
};
(document.getElementById('blurClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Blur, 20);
};
(document.getElementById('opacityClick') as HTMLElement).onclick = function () {
    imageEditorObj.finetuneImage(ImageFinetuneOption.Opacity, 70);
};
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <meta name="description" content="Essential JS 2" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-lists/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-image-editor/styles/material.css" rel="stylesheet" />

    <!--style reference from app-->
    <link href="styles.css" rel="stylesheet" />

    <!--system js reference and configuration-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <div class="control-section">
            <div id="imageeditor" class="row">
            </div>
            <div>
                <button id='hueClick' class='e-btn e-primary'>Hue</button>
                <button id='exposureClick' class='e-btn e-primary'>Exposure</button>
                <button id='blurClick' class='e-btn e-primary'>Blur</button>
                <button id='opacityClick' class='e-btn e-primary'>Opacity</button>
            </div>
        </div>
    </div>
</body>

</html>

Finetune value changing event

The finetuneValueChanging event is triggered when performing fine-tuning on the image. This event is passed an object that contains information about the finetuning event, such as the type of fine-tuning and the value of fine-tuning performed.

The parameter available in the FinetuneEventArgs event is,

FinetuneEventArgs.finetune - The type of fine-tuning as ImageFinetuneOption to be applied in the image editor.

FinetuneEventArgs.value - The fine-tuning value to be applied in the image editor.

FinetuneEventArgs.cancel – Specifies a boolean value to cancel the fine-tuning action.