Inserting image and text from the code behind

2 posts, 0 answers
  1. chintan
    chintan avatar
    5 posts
    Member since:
    Mar 2011

    Posted 26 May 2015 Link to this post



    I would like to insert an image and text from the code behind once user has uploaded a photo with ability to re-position both (inserted image and text).


    Currently I have followed this Demo to achieve uploaded image and showing into rad image editor correctly but same time i would like to insert an overlay image (e.g. water mark/company logo) and some text before showing it into rad image editor from the code behind (or may be from the client side - if possible).


    Also both (inserted image and text) should be allowed to re-position once it is shown in rad image editor.


    Any help would be really appreciated.






  2. Vessy
    Vessy avatar
    2067 posts

    Posted 27 May 2015 Link to this post

    Hi Chintan,

    You can insert text and image to the uploaded image by using the EditableImage's InsertImage() and AddText() methods:
    protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args)
        //Handle Uploaded images
        if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null))
            using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Remove(Session.SessionID + "UploadedFile")))
                args.Image = image.Clone();
                //insert image
                System.Drawing.Image imageToInsert = System.Drawing.Image.FromFile(Server.MapPath("~/images/waterMark.png"));
                System.Drawing.Point imageCoords = new System.Drawing.Point(0,0);
                args.Image.InsertImage(imageCoords, imageToInsert);
                //insert text
                System.Drawing.Point textCoords = new System.Drawing.Point(150,150);
                ImageText textToInsert = new ImageText();
                textToInsert.Color = "#ff0000";
                textToInsert.Size = 32;
                textToInsert.Value = "Inserted text";
                args.Image.AddText(textCoords, textToInsert);
                args.Cancel = true;

    Unfortunately, there is no way to allow the user to modify the inserted text/images when they are applied from the server so you can consider using the corresponding client-side methods for inserting images/text.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top