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

Server side resize proportional to edited image then save

2 Answers 112 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Sauge
Top achievements
Rank 1
Sauge asked on 26 Feb 2013, 01:03 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 01 Mar 2013, 01:30 PM
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)
    currentImage.Image.Save(MapPath("~/TestImages/ResizedImage.jpg"))
End Sub

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

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.
0
Sauge
Top achievements
Rank 1
answered on 07 Mar 2013, 02:52 PM
Vesi

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

Thank you very, very much :-))
Tags
ImageEditor
Asked by
Sauge
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Sauge
Top achievements
Rank 1
Share this question
or