This is a migrated thread and some comments may be shown as answers.

Image is not saved after rotation

7 Answers 207 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Chen Jun Ying
Top achievements
Rank 1
Chen Jun Ying asked on 27 Feb 2012, 04:34 AM
Hi
I'm using RadImageEditor to edit an image. Every time when I rotate the image, it seems the image is not saved when I use imgEditor.GetEditableImage(). Any ideas?



7 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 29 Feb 2012, 11:16 AM
Hi Chen,

By design, RadImageEditor collects all operations applied to the image before execute them, and then after saving is triggered all the operations are applied on the server following the order of the stack collected on the client. This is approach is used to be able to provide Undo / Redo functionality and to reduce the number of executed callbacks. Flip, Rotate and Resize are initially visually applied on the client and when the image is saved all client-side operations are applied on the server.

You can force image saving to apply client-side modifications using the applyChangesOnServer() client-side method of RadImageEditor, e.g.:
<telerik:RadImageEditorID="RadImageEditor1"runat="server"ImageUrl="~/ROOT/Sunset.jpg">
</telerik:RadImageEditor>
  
<asp:ButtonText="text" runat="server" OnClientClick="applyModifications();return false;"/>
  
<script type="text/javascript">
    function applyModifications()
    {
        $find("<%=RadImageEditor1.ClientID %>").applyChangesOnServer();
    }
</script>


Greetings,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chen Jun Ying
Top achievements
Rank 1
answered on 01 Mar 2012, 12:04 AM
Thanks Dobromir.

The image is read from database in binary format. How client method applyChangesOnServer() can trigger a server method to update the image data?  
 
 
Just one more question. Is it possible to customize the popup 
dialogue when clicking the built-in 'Save' command? I would like to skip the dialogue and save any changes . 
0
Dobromir
Telerik team
answered on 01 Mar 2012, 12:52 PM
Hi Chen,

Please accept my sincere apologies for not being clear enough in my previous answer.

RadImageEditor applies modifications made to the actual image file using callbacks. Most of the commands, except AddText, Crop and InsertImage, initially are only visualized on the client and are stored in a queue, and when a server-side Save event is triggered all the stored commands get applied to the actual image file.

The RadImageEditor's client-side method applyChangesOnServer() is triggering the ImageChanging server-side event and can be used to manually force the modifications that are only visualized at this point to be actually applied to the editableImage.

Now regarding your second question, you can modify the Save command to avoid the dialog and directly save the image on the server by handling the OnClientCommandExecuting client-side event of RadImageEditor, e.g.:
<telerik:RadImageEditor ID="RadImageEditor1" runat="server" ImageUrl="~/ROOT/SAM_0310.JPG" OnImageSaving="RadImageEditor1_ImageSaving" OnClientCommandExecuting="imageEditorCommandExecuting">
    <Tools>
        <telerik:ImageEditorToolGroup>
            <telerik:ImageEditorTool CommandName="Save" />
            <telerik:ImageEditorTool CommandName="RotateLeft" />
            <telerik:ImageEditorTool CommandName="RotateRight" />
        </telerik:ImageEditorToolGroup>
    </Tools>
</telerik:RadImageEditor>
<script type="text/javascript">
    function imageEditorCommandExecuting(imageEditor, args)
    {
        if (args.get_commandName() == "Save") {
            args.set_cancel(true);
 
            imageEditor.saveImageOnServer("ImageName", true);
        }
 
    }
</script>

You can find detailed information regarding the RadImageEditor's client-side API in our online documentation.

Kind regards,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chen Jun Ying
Top achievements
Rank 1
answered on 02 Mar 2012, 01:18 PM
Dobromir,

Thanks for your detail explanation. It helps me a lot.
Just one more question. Does this OnClientCommandExecuting client method work with RadAjaxManager? Will it fire AjaxLoadingPanel?
Thanks
0
Rumen
Telerik team
answered on 05 Mar 2012, 12:22 PM
Hello,

You can use the solution provided in the following demo Explicit Show/Hide to show the AjaxLoadingPanel in the OnClientCommandExecuting client side event of RadImageManager.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
vab
Top achievements
Rank 1
answered on 14 Feb 2013, 12:32 PM
this is not working at my side

how this javascript function will get called
0
Vessy
Telerik team
answered on 19 Feb 2013, 07:48 AM
Hi Vab,

If you are talking about the imageEditorCommandExecuting() function, it has to be assigned as a handler to the the OnClientCommandExecuting event:
<telerik:RadImageEditor ID="RadImageEditor1" runat="server" ImageUrl="~/ROOT/SAM_0310.JPG" OnClientCommandExecuting="imageEditorCommandExecuting">
...

If no - could you elaborate on which JavaScript function exactly do you want to call?

Kind regards,
Vesi
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ImageEditor
Asked by
Chen Jun Ying
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Chen Jun Ying
Top achievements
Rank 1
Rumen
Telerik team
vab
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or