Selection and Cropping in the Vue Image Editor component
03 Sep 202624 minutes to read
The cropping feature in the Image Editor allows you to select and crop specific regions of an image. The selection can be a custom rectangle, a square, a circle, or an aspect-ratio region. Supported aspect ratios are 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 5:7, 7:5, 9:16, and 16:9.
To perform a selection, call the select method to define the desired selection area within the image. Once the selection is made, call the crop method to crop the image to that region. This enables you to extract and focus on specific parts of the image while discarding the rest.
Insert custom / square / circle region
The select method allows to perform selection based on the type of selection. Here, the select method is used to perform the selection as custom, circle, or square. The selection region can also be customized using the select method based on the parameters below.
type - Specify the type of selection
startX - Specify the x-coordinate of the selection region’s starting point
startY - Specify the y-coordinate of the selection region’s starting point
width - Specify the width of the selection region
height - Specify the height of the selection region
Here is an example of square selection using the select method.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="created"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Square selection</ejs-button>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const toolbar = [];
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const btnClick = () => {
imageEditorObj.value.ej2Instances.select("Square");
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="onCreated"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Square selection</ejs-button>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent,
"ejs-button": ButtonComponent
},
data: function () {
return {
toolbar: []
};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
btnClick: function () {
this.$refs.imageEditorObj.ej2Instances.select("Square");
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>Insert selection based on aspect ratio
The select method also supports aspect-ratio selections: 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 5:7, 7:5, 9:16, and 16:9. Pass the ratio as the type and (optionally) the starting coordinates:
-
type: The aspect ratio as a string — e.g.,'16:9','4:3','1:1'. -
startX(optional): The x-coordinate of the selection region’s starting point, in pixels. -
startY(optional): The y-coordinate of the selection region’s starting point, in pixels.
The following example shows a ratio selection using the select method.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="created"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Ratio selection</ejs-button>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const toolbar = [];
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const btnClick = () => {
imageEditorObj.value.ej2Instances.select("16:9");
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="onCreated"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Ratio selection</ejs-button>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent,
"ejs-button": ButtonComponent
},
data: function () {
return {
toolbar: []
};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
btnClick: function () {
this.$refs.imageEditorObj.ej2Instances.select("16:9");
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>Crop an image
The crop method allows cropping based on the selected region. Here is an example of cropping the selection region using the crop method.
Here is an example of circle cropping using the select and crop method.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="created"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Circle crop</ejs-button>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const toolbar = [];
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const btnClick = () => {
imageEditorObj.value.ej2Instances.select("Circle");
imageEditorObj.value.ej2Instances.crop();
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :toolbar="toolbar"
:created="onCreated"></ejs-imageeditor>
<ejs-button cssClass="e-img-button" :isPrimary="true" v-on:click="btnClick">Circle crop</ejs-button>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent,
"ejs-button": ButtonComponent
},
data: function () {
return {
toolbar: []
};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
btnClick: function () {
this.$refs.imageEditorObj.ej2Instances.select("Circle");
this.$refs.imageEditorObj.ej2Instances.crop();
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>Cropping event
The cropping event fires when cropping is performed on the image. The event receives a CropEventArgs object that contains the start and end points of the selection region.
The parameter available in the cropping event is,
-
CroppingEventArgs.startPoint– The x and y coordinates of a start point as ImageEditorPoint of the selection region. -
CroppingEventArgs.endPoint- The x and y coordinates of an end point as ImageEditorPoint of the selection region. -
CroppingEventArgs.cancel- To cancel the cropping action.
Maintaining original image size during cropping
When an image is cropped, the editor typically scales it up to improve visibility within the canvas. To prevent this scaling and keep the original cropping size, bind to the cropping event and set args.preventScaling to true. This keeps the image size consistent during cropping and ensures the saved image retains its original cropping size without being enlarged.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :created="created"
@cropping="onCropping"></ejs-imageeditor>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const onCropping = (args) => {
args.preventScaling = true;
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px" :created="onCreated"
@cropping="onCropping"></ejs-imageeditor>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent,
},
data: function () {
return {};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
onCropping: function (args) {
args.preventScaling = true;
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>SelectionChanging event
The selection region can be changed programmatically by using selectionChanging event. This event is activated during resizing the selection using mouse, and it allows for alterations to the selection region by adjusting the specified properties.
The SelectionChangeEventArgs is used in this event to customize the selection and it has the following parameters.
-
SelectionChangeEventArgs.action - The type of action such as inserting or resizing.
-
SelectionChangeEventArgs.currentSelectionPoint - Represents all the details of the selection including its type, position, width, and height after the current action as CropSelectionSettings.
-
SelectionChangeEventArgs.previousSelectionPoint - Represents all the details of the selection including its type, position, width, and height before this current action as CropSelectionSettings.
Locking selection area during cropping
By default the selection area can be resized from all corners and edges. To lock it to its current size, bind to the resizing event and set cancel to true. This will lock the selection area, preventing any adjustments to its size.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px"
:selectionChanging="selectionChanging" :created="created"></ejs-imageeditor>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const selectionChanging = (args) => {
if (args.action == "resize") {
args.currentSelectionSettings = args.previousSelectionSettings;
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px"
:selectionChanging="selectionChanging" :created="onCreated"></ejs-imageeditor>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent,
},
data: function () {
return {};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
selectionChanging: function (args) {
if (args.action == "resize") {
args.currentSelectionSettings = args.previousSelectionSettings;
}
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>Cropping with custom ratio selection
Users can perform cropping either through the toolbar or by using our public methods. While predefined ratio selections are available in the toolbar, users can also crop with custom ratios using our public method, select. Regardless of the ratio type used, the selection will adhere to the specified ratio, even when resizing the selection area.
Here is an example of cropping with a custom ratio selection using the selectionChanging event.
<template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px"
:selectionChanging="selectionChanging" :created="created"></ejs-imageeditor>
</div>
</template>
<script setup>
import { ImageEditorComponent as EjsImageeditor } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
import { ref } from "vue";
const imageEditorObj = ref(null);
const created = () => {
const imageEditor = imageEditorObj.value?.ej2Instances;
if (!imageEditor) return;
const imageUrl = Browser.isDevice
? "https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg"
: "https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg";
imageEditor.open(imageUrl);
};
const selectionChanging = (args) => {
if (args.action === "insert" && args.currentSelectionSettings.type === "Custom") {
args.currentSelectionSettings.height = 200;
args.currentSelectionSettings.width = 200;
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style><template>
<div>
<ejs-imageeditor id="image-editor" ref="imageEditorObj" height="350px" width="550px"
:selectionChanging="selectionChanging" :created="onCreated"></ejs-imageeditor>
</div>
</template>
<script>
import { ImageEditorComponent } from "@syncfusion/ej2-vue-image-editor";
import { Browser } from "@syncfusion/ej2-base";
export default {
name: "App",
components: {
"ejs-imageeditor": ImageEditorComponent
},
data: function () {
return {};
},
methods: {
onCreated() {
let imageEditor = this.$refs.imageEditorObj?.ej2Instances;
if (!imageEditor) return;
let imageUrl = Browser.isDevice
? 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/flower.jpeg'
: 'https://ej2.syncfusion.com/vue/documentation/image-editor/images/bridge.jpeg';
imageEditor.open(imageUrl);
},
selectionChanging: function (args) {
if (args.action === "insert" && args.currentSelectionSettings.type === "Custom") {
args.currentSelectionSettings.height = 200;
args.currentSelectionSettings.width = 200;
}
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";
#image-editor {
width: 550px !important;
height: 350px !important;
}
</style>