Server side resize proportional to edited image then save

3 posts, 1 answers
  1. Sauge
    Sauge avatar
    24 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Hi there

    Does anyone know how I can resize the image proportionally to whatever image is in the editor at the time and then save it?

    To Clarify:
    What I would like to be able to do is:
    When the user clicks my save button (outside the image editor) whatever image is in the editor would be automatically resized proportionally to whatever image is in the editor (just in case it has been cropped or rotated or whatever) to width and/or height that I would specify and then saved with the new dimensions. i.e. if I specify width of 200, the height would be worked out proportionally so that the image would retain the same aspect ratio as it had at the time of saving and save with a width of 200 and a height of ?
    All of this, server side (VB)

    I am able to save edited images with my save button, but don't know how to do the resizing bit.
    Resizing must be proportional so that the image isn't distorted in any way because of my new dimensions

    Any help gratefully received :-)
  2. Answer
    Vessy avatar
    1357 posts

    Posted 01 Mar 2013 Link to this post

    Hi Sauge,

    If you use the built-in ImageEditor's resize functionality you, the resize ratio could be set only on the client. Nevertheless, you could take the edited image Server-side and to resize it manually by taking into account the original  width:height ration. Note, that the changes have to be applied to the image before any Server-side manipulations - otherwise all previous changes will be lost. For instance, it could be done in a similar way:
    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Dim currentImage As EditableImage = RadImageEditor1.GetEditableImage()
        Dim height As Integer = currentImage.Height
        Dim width As Integer = currentImage.Width
        Dim ration As Double = CDbl(height) / width
        Dim newWidth As Integer = 200
        Dim newHeight As Integer = CInt(newWidth * ration)
        currentImage.Resize(newWidth, newHeight)
    End Sub

    I hope this would be helpful for you in implementing your scenario.

    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.
  3. Telerik UI for ASP.NET Core is out
  4. Sauge
    Sauge avatar
    24 posts
    Member since:
    Feb 2013

    Posted 07 Mar 2013 Link to this post


    You are a total star!!!!!  That worked beautifully. 

    Thank you very, very much :-))
Back to Top