Search results

ImageEditor

The Image Editor is a graphical user interface for editing images.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
});
imageObj.appendTo('#imageeditor');

Properties

allowUndoRedo

boolean

Specifies a boolean value whether enable undo/redo operations in the image editor.

Defaults to true

cssClass

string

Defines one or more CSS classes that can be used to customize the appearance of an Image Editor component.

Defaults to

disabled

boolean

Defines whether an Image Editor component is enabled or disabled.

Defaults to false

finetuneSettings

FinetuneSettingsModel

Specifies the finetune settings option which can be used to perform color adjustments in the image editor control.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  finetuneSettings: {
    brightness: { min: -100, max: 100, defaultValue: 0 },
    contrast: { min: -100, max: 100, defaultValue: 0 }
  }
});
imageObj.appendTo('#imageeditor');

fontFamily

FontFamilyModel

Predefine the font families that populate in font family dropdown list from the toolbar.

height

string

Specifies the height of the Image Editor.

Defaults to ‘100%’

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to

quickAccessToolbarTemplate

string | Function

Specifies a template for the quick access toolbar. Use this property to customize the quick access toolbar.

Defaults to null

selectionSettings

SelectionSettingsModel

Specifies the selection settings to customize selection. A ‘SelectionSettingsModel’ value that specifies the the customization related options which are enabled in image editor control. The default value is null.

showQuickAccessToolbar

boolean

Specifies whether to show/hide the quick access toolbar.

Defaults to true

theme

string | Theme

Specifies the theme of the Image Editor. The appearance of the shape selection in Image Editor is determined by this property.

Defaults to Theme.Bootstrap5

toolbar

[]

Specifies the toolbar items to perform UI interactions. It accepts both string[] and ItemModel[] to configure its toolbar items. The default value is null. If the property is not defined in the control, the default toolbar will be rendered with preconfigured toolbar commands. If the property is defined as empty collection, the toolbar will not be rendered. The preconfigured toolbar commands are

  • Crop: helps to crop an image as ellipse, square, various ratio aspects, custom selection with resize, drag and drop.
  • Annotate: help to insert a shape on image that supports rectangle, ellipse, line, arrow, path, text, image and freehand drawing with resize, drag and drop, and customize its appearance.
  • Transform: helps to rotate and flip an image.
  • Finetunes: helps to perform adjustments on an image.
  • Filters: helps to perform predefined color filters.
  • ZoomIn: performs zoom-in an image.
  • ZoomOut: performs zoom-out an image.
  • Save: save the modified image.
  • Open: open an image to perform editing.
  • Reset: reset the modification and restore the original image.
<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  toolbar: ['Crop', 'ZoomIn', 'ZoomOut', 'Transform', {text: 'Custom'}]
});
imageObj.appendTo('#imageeditor');

Defaults to null

toolbarTemplate

string | Function

Specifies a custom template for the toolbar of an image editor control. A string that specifies a custom template for the toolbar of the image editor. If this property is defined, the ‘toolbar’ property will not have any effect.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
<script id="toolbarTemplate" type="text/x-template">
  <div class = 'e-toolbar'>
    <button id= 'dltbtn'>Custom</button>
  </div>
</script>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  toolbarTemplate: '#toolbarTemplate'
});
imageObj.appendTo('#imageeditor');

Defaults to null

width

string

Specifies the width of an Image Editor.

Defaults to ‘100%’

zoomSettings

ZoomSettingsModel

Specifies the zoom settings to perform zooming action. A ‘ZoomSettingsModel’ value that specifies the the zoom related options which are enabled in image editor control. The default value is null.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor, ZoomTrigger } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  zoomSettings: {
    minZoomFactor: 1,
    maxZoomFactor: 100,
    zoomFactor: 1,
    zoomTrigger: ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar | ZoomTrigger.Commands,
    zoomPoint: new Point {x: 500, y: 500}
  }
});
imageObj.appendTo('#imageeditor');

Methods

addEventListener

Adds the handler to the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event
handler Function Specifies the call to run when the event occurs.

Returns void

appendTo

Appends the control within the given HTML element

Parameter Type Description
selector (optional) string | HTMLElement Target element where control needs to be appended

Returns void

applyImageFilter

Filtering an image with the given type of filters.

Parameter Type Description
filterOption ImageFilterOption Specifies the filter options to the image.

Returns void

attachUnloadEvent

Adding unload event to persist data when enable persistence true

Returns void

canRedo

Specifies if it’s possible to redo the last recent action made in an Image Editor.

Returns boolean

canUndo

Specifies if it’s possible to undo the last recent action made in an Image Editor.

Returns boolean

clearSelection

Clears the current selection performed in the image editor.

Parameter Type Description
resetCrop (optional) boolean Specifies to reset last cropped image.

Returns void

cloneShape

Duplicates a shape based on the given shape ID in the ImageEditor. Use ‘getShapeSettings’ method to get the shape and then pass a shapeId from the returned shape to clone a shape.

Parameter Type Description
shapeId string Specifies the shape id to clone a shape on an image.

Returns boolean

crop

Crops an image based on the selection done in the image editor.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.select('16:9', 10, 10);
    imageObj.crop();
  }
});
imageObj.appendTo('#imageeditor');

Returns boolean

dataBind

When invoked, applies the pending property changes immediately to the component.

Returns void

deleteShape

Deletes a shape based on the given shape id. Use ‘getShapeSettings’ method to get the shape id which is then passed to perform selection.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.drawEllipse(10, 10, 40, 60);
    imageObj.drawEllipse(10, 80, 40, 130);
    imageObj.selectShape('shape_1');
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
id string Specifies the shape id to delete the shape on an image.

Returns void

detachUnloadEvent

Removing unload event to persist data when enable persistence true

Returns void

drawArrow

Draw arrow on an image.

Parameter Type Description
startX (optional) number – Specifies start point x-coordinate of arrow.
startY (optional) number – Specifies start point y-coordinate of arrow.
endX (optional) number Specifies end point x-coordinates of arrow.
endY (optional) number Specifies end point y-coordinates of the arrow.
strokeWidth (optional) number Specifies the stroke width of arrow.
strokeColor (optional) string Specifies the stroke color of arrow.
arrowStart (optional) ArrowheadType – Specifies the type of arrowhead for start position. The default value is ‘None’.
arrowEnd (optional) ArrowheadType – Specifies the type of arrowhead for end position. The default value is ‘SolidArrow’.
isSelected (optional) boolean Specifies to show the arrow in the selected state.

Returns boolean

drawEllipse

Draw ellipse on an image.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.drawEllipse(10, 10, 40, 60);
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
x (optional) number Specifies x-coordinate of ellipse.
y (optional) number Specifies y-coordinate of ellipse.
radiusX (optional) number Specifies the radius x point for the ellipse.
radiusY (optional) number Specifies the radius y point for the ellipse.
strokeWidth (optional) number Specifies the stroke width of ellipse.
strokeColor (optional) string Specifies the stroke color of ellipse.
fillColor (optional) string Specifies the fill color of the ellipse.
degree (optional) number Specifies the degree to rotate the ellipse.
isSelected (optional) boolean Specifies to show the ellipse in the selected state.

Returns boolean

drawFrame

Draw a frame on an image.

Parameter Type Description
frameType FrameType Specifies the frame option to be drawn on an image.
color (optional) string Specifies the color of a frame on an image. The default value is ‘#fff’.
gradientColor (optional) string Specifies the gradient color of a frame on an image. The default value is ‘’.
size (optional) number Specifies the size of the frame as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 20 if not specified.
inset (optional) number Specifies the inset value for line, hook, and inset type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
offset (optional) number Specifies the offset value for line and inset type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
borderRadius (optional) number Specifies the border radius for line-type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
frameLineStyle (optional) FrameLineStyle Specifies the type of line to be drawn for line-type frames. Default to Solid if not specified.
lineCount (optional) number Specifies the number of lines for line-type frames. Defaults to 0 if not specified.

Returns boolean

drawImage

Draw an image as annotation on an image.

Parameter Type Description
data string | ImageData Specifies url of the image or image data.
x (optional) number Specifies x-coordinate of a starting point for an image.
y (optional) number Specifies y-coordinate of a starting point for an image.
width (optional) number Specifies the width of the image.
height (optional) number Specifies the height of the image.
isAspectRatio (optional) boolean Specifies whether to maintain aspect ratio or not.
degree (optional) number Specifies the degree to rotate the image.
opacity (optional) number Specifies the value for the image.
isSelected (optional) boolean Specifies to show the image in the selected state.

Returns boolean

drawLine

Draw line on an image.

Parameter Type Description
startX (optional) number – Specifies start point x-coordinate of line.
startY (optional) number – Specifies start point y-coordinate of line.
endX (optional) number Specifies end point x-coordinates of line.
endY (optional) number Specifies end point y-coordinates of the line.
strokeWidth (optional) number Specifies the stroke width of line.
strokeColor (optional) string Specifies the stroke color of line.
isSelected (optional) boolean Specifies to show the line in the selected state.

Returns boolean

drawPath

Draw path on an image.

Parameter Type Description
pointColl Point[] – Specifies collection of start and end x, y-coordinates of path.
strokeWidth (optional) number Specifies the stroke width of path.
strokeColor (optional) string Specifies the stroke color of path.
isSelected (optional) boolean Specifies to show the path in the selected state.

Returns boolean

drawRectangle

Draw a rectangle on an image.

Parameter Type Description
x (optional) number Specifies x-coordinate of rectangle.
y (optional) number Specifies y-coordinate of rectangle.
width (optional) number Specifies the width of the rectangle.
height (optional) number Specifies the height of the rectangle.
strokeWidth (optional) number Specifies the stroke width of rectangle.
strokeColor (optional) string Specifies the stroke color of rectangle.
fillColor (optional) string Specifies the fill color of the rectangle.
degree (optional) number Specifies the degree to rotate the rectangle.
isSelected (optional) boolean Specifies to show the rectangle in the selected state.

Returns boolean

drawText

Draw a text on an image.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.drawText(10, 10, 'Syncfusion', 'Arial', 12, true, true, '#000');
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
x (optional) number Specifies x-coordinate of text.
y (optional) number Specifies y-coordinate of text.
text (optional) string Specifies the text to add on an image.
fontFamily (optional) string Specifies the font family of the text.
fontSize (optional) number Specifies the font size of the text.
bold (optional) boolean Specifies whether the text is bold or not.
italic (optional) boolean Specifies whether the text is italic or not.
color (optional) string Specifies font color of the text.
isSelected (optional) boolean Specifies to show the text in the selected state.

Returns boolean

enableTextEditing

Enable text area editing in the ImageEditor.

Returns void

export

Export an image using the specified file name and the extension.

Parameter Type Description
type (optional) string Specifies a format of image to be saved.
fileName (optional) string – Specifies a file name to be saved

Returns void

finetuneImage

Finetuning an image with the given type of finetune and its value in the image editor.

Parameter Type Description
finetuneOption ImageFinetuneOption Specifies the finetune options to be performed in the image.
value number Specifies the value for finetuning the image.

Returns void

flip

Flips an image by horizontally or vertically in the image editor.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.zoom(40, {x: 400, y: 400});
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
direction Direction Specifies the direction to flip the image.
A horizontal direction for horizontal flipping and vertical direction for vertical flipping.

Returns void

freehandDraw

Enable or disable a freehand drawing in an Image Editor.

Parameter Type Description
value boolean Specifies a value whether to enable or disable freehand drawing.

Returns void

getImageData

Returns an image as ImageData to load it in to a canvas.

Returns ImageData

getImageDimension

Get the dimension of an image in the image editor such as x, y, width, and height. The method helps to get dimension after cropped an image.

Returns Dimension

getImageFilter

Update filter to the canvas in the ImageEditor.

Parameter Type Description
filterOption ImageFilterOption Specifies the filter options to the image.

Returns string

getLocalData

Returns the persistence data for component

Returns any

getRootElement

Returns the route element of the component

Returns HTMLElement

getShapeSetting

Get particular shapes details based on id of the shape which is drawn on an image editor.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor, ShapeSettings } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.drawEllipse(10, 10, 40, 60);
    imageObj.drawEllipse(10, 80, 40, 130);
    let shape: ShapeSettings = imageObj.getShapeSetting('shape_1');
    console.log(shape.type);
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
id string Specifies the shape id on an image.

Returns ShapeSettings

getShapeSettings

Get all the shapes details which is drawn on an image editor.

Returns ShapeSettings[]

handleUnload

Handling unload event to persist data when enable persistence true

Returns void

open

Opens an image as URL or ImageData for editing in an image editor.

Parameter Type Description
data string | ImageData Specifies url of the image or image data.

Returns void

pan

Enable or disable a panning on the Image Editor.

Parameter Type Description
value boolean Specifies a value whether enable or disable panning.

Returns void

redo

Redo the last user action that was undone by the user or undo method.

Returns void

refresh

Applies all the pending property changes and render the component again.

Returns void

removeEventListener

Removes the handler from the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event to remove
handler Function Specifies the function to remove

Returns void

reset

Reset all the changes done in an image editor and revert to original image.

Returns void

resize

Resize an image by changing its width and height.

Parameter Type Description
width number Specifies the width of an image.
height number Specifies the height of an image.
isAspectRatio (optional) boolean Specifies whether the scaling option is enabled or not.

Returns boolean

rotate

Rotate an image to clockwise and anti-clockwise.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.rotate(90);
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
degree number Specifies a degree to rotate an image.
A positive integer value for clockwise and negative integer value for anti-clockwise rotation.

Returns boolean

select

Perform selection in an image editor. The selection helps to crop an image.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.select('16:9', 10, 10);
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
type string Specifies the shape - circle / square / custom selection / pre-defined ratios.
startX (optional) number – Specifies the start x-coordinate point of the selection.
startY (optional) number – Specifies the start y-coordinate point of the selection.
width (optional) number Specifies the width of the selection area.
height (optional) number Specifies the height of the selection area.

Returns void

selectShape

Select a shape based on the given shape id. Use ‘getShapeSettings’ method to get the shape id which is then passed to perform selection.

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  created: () => {
    imageObj.open('https://ej2.syncfusion.com/demos/src/image-editor/images/bridge.png');
    imageObj.drawEllipse(10, 10, 40, 60);
    imageObj.drawEllipse(10, 80, 40, 130);
    imageObj.selectShape('shape_1');
  }
});
imageObj.appendTo('#imageeditor');
Parameter Type Description
id string Specifies the shape id to select a shape on an image.

Returns boolean

straightenImage

Straightens an image by rotating it clockwise or counterclockwise.

Parameter Type Description
degree number The degree value specifying the amount of rotation for straightening the image.
Positive values indicate clockwise rotation, while negative values indicate counterclockwise rotation.

Returns boolean

undo

Reverse the last action which performed by the user in the Image Editor.

Returns void

update

To refresh the Canvas Wrapper.

Returns void

updateShape

This method is used to update the existing shapes by changing its height, width, color, and font styles in the component. Use ‘getShapeSettings’ method to get the shape which is then passed to change the options of a shape.

Parameter Type Description
setting ShapeSettings Specifies the shape settings to be updated for the shape on an image.
isSelected (optional) boolean Specifies to show the shape in the selected state.

Returns boolean

zoom

Zoom in or out on a point in the image editor.

Parameter Type Description
zoomFactor number The percentage-based zoom factor to use (e.g. 20 for 2x zoom).
zoomPoint (optional) Point The point in the image editor to zoom in/out on.

Returns void

Inject

Dynamically injects the required modules to the component.

Parameter Type Description
moduleList Function[] ?

Returns void

Events

beforeSave

EmitType<BeforeSaveEventArgs>

Event callback that is raised before an image is saved.

click

EmitType<ImageEditorClickEventArgs>

Event callback that is raised while clicking on an image in the Image Editor.

created

EmitType<Event>

Event callback that is raised after rendering the Image Editor component.

cropping

EmitType<CropEventArgs>

Event callback that is raised while cropping an image.

destroyed

EmitType<Event>

Event callback that is raised once the component is destroyed with its elements and bound events.

fileOpened

EmitType<OpenEventArgs>

Event callback that is raised once an image is opened in an Image Editor.

finetuneValueChanging

EmitType<FinetuneEventArgs>

Event callback that is raised when applying fine tune to an image.

flipping

EmitType<FlipEventArgs>

Event callback that is raised while flipping an image.

frameChange

EmitType<FrameChangeEventArgs>

Event callback that is raised while applying frames on an image.

imageFiltering

EmitType<ImageFilterEventArgs>

Event callback that is raised when applying filter to an image.

panning

EmitType<PanEventArgs>

Event callback that is raised while panning an image.

quickAccessToolbarItemClick

EmitType<ClickEventArgs>

Event callback that is raised once the quick access toolbar item is clicked.

quickAccessToolbarOpen

EmitType<QuickAccessToolbarEventArgs>

Event callback that is raised when opening the quick access toolbar.

resizing

EmitType<ResizeEventArgs>

Event callback that is raised while resizing an image.

rotating

EmitType<RotateEventArgs>

Event callback that is raised while rotating an image.

saved

EmitType<SaveEventArgs>

Event callback that is raised once an image is saved.

selectionChanging

EmitType<SelectionChangeEventArgs>

Event callback that is raised while changing selection in an Image Editor.

shapeChange

EmitType<ShapeChangeEventArgs>

Event callback that is raised after shape changing action is performed in an image editor.

shapeChanging

EmitType<ShapeChangeEventArgs>

Event callback that is raised while changing shapes in an Image Editor.

toolbarCreated

EmitType<ToolbarEventArgs>

Event callback that is raised once the toolbar is created.

toolbarItemClicked

EmitType<ClickEventArgs>

Event callback that is raised once the toolbar item is clicked.

toolbarUpdating

EmitType<ToolbarEventArgs>

Event callback that is raised while updating/refreshing the toolbar

<div style="height: 500px">
  <div id='imageeditor'></div>
</div>
import { ImageEditor, ToolbarEventArgs } from '@syncfusion/ej2-image-editor';

let imageObj: ImageEditor = new ImageEditor({
  showQuickAccessToolbar: true,
  toolbarUpdating: (args: ToolbarEventArgs) => {
    if (args.toolbarType === 'shapes') {
      args.toolbarItems = ['fillColor', 'strokeColor', 'strokeWidth', { text: 'Click', template: '<button class="e-btn" id="shape">Click</button>', tooltipText: 'Click', prefixIcon: 'e-expand', id: 'Click' }];
    }
  },
});
imageObj.appendTo('#imageeditor');

zooming

EmitType<ZoomEventArgs>

Event callback that is raised while zooming an image.