RadImageEditor

1 Answer 347 Views
ImageEditor
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
SSirica asked on 30 Mar 2022, 02:21 PM

RadImageEditor maybe one of the worst thought out controls you have in your control suite.  It could have been easy...if you consulted programmers who actually have to use this.    Rant over, now lets get to the reson why we're here.  

The source of my images are stored in a SQL DB.  After jumping thru spiked hoops...I figured out how to save and load the images in the RadImageEditor.  For the record, way harder than it needed to be.  My problem is after I make changes to the image, ie maybe a resize, there is no easy way to to get the altered image.  I thought the following code would do the trick:

Dim img As EditableImage = RadImageEditor1.GetEditableImage

boy was I wrong.  I've seen the posts about CanvasMode...doesn't change the outcome.  I've tried all 3 settings.  I've tried changing the property in the aspx page.  I've tried changing the property in the code behind.  Result is always the unaltered image.  Would it have killed you to have a GetChangedImage option?

I'm controlling the events in the code behind.  I'm not using client events.  I want to press a button and in the code behind/server code...save the data on my screen to a database and I would like to know how to include the altered image in that save?  I'm not using any of the buttons on the RadImageEditor.  

I would appreciate the code in VB and I would appreciate an actual example not a link to some demo because I've already been thru them with a fine tooth comb. 

Thanks in advance.  

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Apr 2022, 12:27 PM

Hi Steve,

For your convenience, I prepared an example demonstrating how to achieve the saving on the modified image on the server through an external button in VB.NET code.

The important is to:

  • Set the ImageEditor's CanvasMode property to No
  • Call the SaveEditableImage method in the Button Click event since the method will trigger the OnImageSaving server-event of the ImageEditor where you can save the edited image to the desired location.

ASPX

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="RadScriptManager1" runat="server">
        </asp:ScriptManager>

        <telerik:RadImageEditor ID="RadImageEditor1" runat="server"
            ImageUrl="~/Bear.png"
            CanvasMode="No"
            OnImageSaving="RadImageEditor1_ImageSaving">
        </telerik:RadImageEditor>
        <telerik:RadButton ID="Save" runat="server" Text="Save" OnClick="Save_Click" />
    </form>
</body>
</html>

ASPX.VB

Partial Class Default2
    Inherits System.Web.UI.Page


    Protected Sub RadImageEditor1_ImageSaving(sender As Object, args As Telerik.Web.UI.ImageEditorSavingEventArgs)
        Dim img As Telerik.Web.UI.ImageEditor.EditableImage = args.Image
        img.Image.Save(MapPath("~/Images/Bear1.png"))
        args.Cancel = True
    End Sub

    Protected Sub Save_Click(sender As Object, e As EventArgs)
        RadImageEditor1.SaveEditableImage("bear.png", True)
    End Sub

End Class

The scenario is explained in the following forum thread - https://www.telerik.com/forums/save-button-outside-of-radimageeditor

Regards,
Rumen
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.

SSirica
Top achievements
Rank 3
Iron
Iron
Iron
commented on 04 Apr 2022, 12:58 PM

Thanks for the solution.  It's klugie, but I'm sure I can cobble something together to get it to work. 

Obviously I wanted to find a solution, but my main point was this doesn't have to be this hard.  If you can get the "args.Image" or the Edited Image outside of the ImageSaving event this all would be a non issue.  

 
Tags
ImageEditor
Asked by
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Rumen
Telerik team
Share this question
or