Finetune in React Image Editor
28 Aug 202615 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.
The finetuneImage method performs fine-tuning on the image and accepts two parameters: an ImageFinetuneOption specifying the option, and a numeric value indicating intensity. Supported options are listed below; the value is a numeric value (typical range -100 to 100, step 1).
ImageFinetuneOption enumeration:
-
Blur- Adjust the blur of the image. -
Brightness- Adjust the brightness of the image. -
Contrast- Adjust the contrast of the image. -
Exposure- Adjust the exposure of the image. -
Hue- Adjust the hue of the image. -
Opacity- Adjust the opacity of the image. -
Saturation- Adjust the saturation of the image.
Adjust the Brightness, Contrast, and Saturation
Here is an example of brightness, contrast, and saturation fine-tuning using the finetuneImage method.
import { ImageEditorComponent, ImageFinetuneOption } from '@syncfusion/ej2-react-image-editor';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
export default class App extends React.Component {
imgObj;
imageEditorCreated() {
if (Browser.isDevice) {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
}
else {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
brightnessClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Brightness, 10);
}
contrastClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Contrast, 30);
}
saturationClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Saturation, 100);
}
render() {
return (<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { this.imgObj = img; }} height="350px" created={this.imageEditorCreated.bind(this)} toolbar={[]}></ImageEditorComponent>
<div>
<ButtonComponent cssClass='e-primary' content='Brightness' onClick={this.brightnessClick.bind(this)} />
<ButtonComponent cssClass='e-primary' content='Contrast' onClick={this.contrastClick.bind(this)} />
<ButtonComponent cssClass='e-primary' content='Saturation' onClick={this.saturationClick.bind(this)} />
</div>
</div>);
}
}
ReactDOM.render(<App />, document.getElementById('image-editor'));import { ImageEditorComponent, ImageFinetuneOption } from '@syncfusion/ej2-react-image-editor';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
let imgObj: ImageEditorComponent;
function imageEditorCreated(): void {
if (Browser.isDevice) {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
} else {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
function brightnessClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Brightness, 10);
}
function contrastClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Contrast, 30);
}
function saturationClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Saturation, 100);
}
return (
<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { imgObj = img }} created={imageEditorCreated} toolbar={[]}></ImageEditorComponent>
<div>
<ButtonComponent cssClass='e-primary' content='Brightness' onClick={brightnessClick} />
<ButtonComponent cssClass='e-primary' content='Contrast' onClick={contrastClick} />
<ButtonComponent cssClass='e-primary' content='Saturation' onClick={saturationClick} />
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('image-editor'));<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React Image Editor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css"rel="stylesheet">
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='image-editor'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Adjust the Hue, Exposure, Blur, and Opacity
Here is an example of hue, exposure, blur, and opacity fine-tuning using the finetuneImage method.
import { ImageEditorComponent, ImageFinetuneOption } from '@syncfusion/ej2-react-image-editor';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
export default class App extends React.Component {
imgObj;
imageEditorCreated() {
if (Browser.isDevice) {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
}
else {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
blurClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Blur, 20);
}
exposureClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Exposure, 20);
}
hueClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Hue, 20);
}
opacityClick() {
this.imgObj.finetuneImage(ImageFinetuneOption.Opacity, 70);
}
render() {
return (<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { this.imgObj = img; }} height="350px" created={this.imageEditorCreated.bind(this)} toolbar={[]}></ImageEditorComponent>
<div>
<ButtonComponent cssClass='e-primary' content='Blur' onClick={this.blurClick.bind(this)} />
<ButtonComponent cssClass='e-primary' content='Exposure' onClick={this.exposureClick.bind(this)} />
<ButtonComponent cssClass='e-primary' content='Hue' onClick={this.hueClick.bind(this)} />
<ButtonComponent cssClass='e-primary' content='Opacity' onClick={this.opacityClick.bind(this)} />
</div>
</div>);
}
}
ReactDOM.render(<App />, document.getElementById('image-editor'));import { ImageEditorComponent, ImageFinetuneOption } from '@syncfusion/ej2-react-image-editor';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
let imgObj: ImageEditorComponent;
function imageEditorCreated(): void {
if (Browser.isDevice) {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
} else {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
function blurClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Blur, 20);
}
function exposureClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Exposure, 20);
}
function hueClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Hue, 20);
}
function opacityClick(): void {
imgObj.finetuneImage(ImageFinetuneOption.Opacity, 70);
}
return (
<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { imgObj = img }} created={imageEditorCreated} toolbar={[]}></ImageEditorComponent>
<div>
<ButtonComponent cssClass='e-primary' content='Blur' onClick={blurClick} />
<ButtonComponent cssClass='e-primary' content='Exposure' onClick={exposureClick} />
<ButtonComponent cssClass='e-primary' content='Hue' onClick={hueClick} />
<ButtonComponent cssClass='e-primary' content='Opacity' onClick={opacityClick} />
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('image-editor'));<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React Image Editor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css"rel="stylesheet">
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='image-editor'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Finetune value changing event
The finetuneValueChanging event is triggered while fine-tuning and receives a FinetuneEventArgs object with the following properties (see API):
-
finetune: The finetune option being applied. -
value: The finetune value to be applied. -
cancel: Set totrueto cancel the fine-tuning action.