Unplanned
Last Updated: 05 Nov 2021 10:17 by ADMIN
Brightstar
Created on: 22 Oct 2021 16:46
Category: ImageEditor
Type: Feature Request
1
Provide "Auto-Resize" option when uploading an image

We have an image control that requires an upload to be a specific size.

Rather than making our users have to manually resize their photo to the same size every time, they have requested we resize it for them since we know the size limits (96x96).

I don't see any built-in support for this so I've tried to hack it but even that hasn't worked. The "imageEditor.executeCommand({ command: "OpenPaneImageEditorCommand" })" throws an error when being called from the ImageRendered event, and manually selecting the buttons also does not resize the image.

Link to example: https://jsfiddle.net/atz9ne6g/1/

Code from example:

$("#imageEditor").kendoImageEditor({
    width: 1000,
    height: 800,
    imageLoaded: UploadPhoto_ImageLoaded,
    imageRendered: UploadPhoto_ImageRendered
});

let imageLoaded = false;
function UploadPhoto_ImageLoaded(e) {
    imageLoaded = true;
}

function UploadPhoto_ImageRendered(e) {
    if (imageLoaded) {
        imageLoaded = false;
        //var imageEditor = e.sender;
        // TODO: Auto resize photo to 96x96 when opening popup
        //imageEditor.executeCommand({ command: "OpenPaneImageEditorCommand" });
        //imageEditor.executeCommand({ command: "ResizeImageEditorCommand" });

        $(".k-i-image-resize").click();
        $(".k-formatted-value[title='width']").val(96);
        $(".k-imageeditor-pane-confirm-button").click();
    }
3 comments
ADMIN
Martin
Posted on: 05 Nov 2021 10:17

Hello, 

Currently we do not have a list with the available commands. In the execute event you can check the names of the commands when you use the tools and the corresponding options to it.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Brightstar
Posted on: 29 Oct 2021 20:21
Thank you Martin, that is useful. I wish that had been easier to find. Is there anywhere we can find a documented list of all the commands available via the executeCommand method and maybe the options for those commands?
ADMIN
Martin
Posted on: 29 Oct 2021 15:43

Hello, 

Thank you for submitting a feature request.

In order to dynamically resize an image, you can use the executeCommand method. Please refer to this Dojo example.

Let me know how that works for you.

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.