Getting started with EJ2 JavaScript Image Editor
14 Sep 20263 minutes to read
This section explains the steps required to create a simple Essential® JS 2 Image Editor and demonstrate the basic usage of the Image Editor control in a JavaScript application.
Dependencies
The list of dependencies required to use the Image Editor component in your application is given below:
|-- @syncfusion/ej2-image-editor
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-buttons
|-- @syncfusion/ej2-dropdowns
|-- @syncfusion/ej2-inputs
|-- @syncfusion/ej2-navigations
|-- @syncfusion/ej2-popups
|-- @syncfusion/ej2-splitbuttonsSetup for local environment
Refer to the following steps to set up your local environment.
Step 1: Create a root folder named my-app for your application.
Step 2: Create a my-app/resources folder to store local scripts and styles files.
Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Image Editor control.
Control Initialization
The Essential® JS 2 JavaScript controls can be initialized by using below css styles and Scripts
Add Syncfusion® Image Editor CSS Styles and Scripts
Include the following CSS and JavaScript files from CDN in the <head> section of the index.html file. The ej2-base, ej2-buttons,ej2-inputs, ej2-navigations, ej2-popups, ej2-splitbuttons script is the required dependency package for the Image Editor component.
Styles(CSS):
https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/image-editor/index.cssScripts (javascript):
https://cdn.syncfusion.com/ej2/35.1.37/ej2-base/dist/global/ej2-base.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-buttons/dist/global/ej2-buttons.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-inputs/dist/global/ej2-inputs.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-navigations/dist/global/ej2-navigations.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-popups/dist/global/ej2-popups.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-splitbuttons/dist/global/ej2-splitbuttons.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-image-editor/dist/global/ej2-image-editor.min.jsAdd the Image Editor control to the application
Add an HTML DIV element with the id attribute set to image editor in your index.html file:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Essential JS 2 - Image Editor</title>
<link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/image-editor/index.css" rel="stylesheet" />
<!-- Essential JS 2 Image Editor's dependent scripts -->
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-base/dist/global/ej2-data.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-buttons/dist/global/ej2-buttons.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-lists/dist/global/ej2-lists.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-inputs/dist/global/ej2-inputs.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-navigations/dist/global/ej2-navigations.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-popups/dist/global/ej2-popups.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-splitbuttons/dist/global/ej2-splitbuttons.min.js" type="text/javascript"></script>
<!-- Essential JS 2 Image Editor's global script -->
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-image-editor/dist/global/ej2-image-editor.min.js" type="text/javascript"></script>
<!--style reference from app-->
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<!--element which is going to render-->
<div id="imageeditor">
</div>
<script>
new ej.imageeditor.ImageEditor({
width: '550px',
height: '350px',
}, '#imageeditor');
</script>
</body>
</html>