New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Change Dimensions

  • Undo
  • Redo
  • Resize
Zoom:100%Size:0x0pxPos.:(-,-)Last Action:None

Sometimes we need to make our images smaller (or bigger), so they are more convenient to use. RadImageEditor ships with a Resize tool that allows the users to easily change the width and height of an image by setting custom dimensions, using predefined ones, or using a percentage of the original image. The tool can be shown on the ToolBar by creating a ImageEditorTool with CommandName="Resize".
The image can be resized programmatically on the client by using the RadImageEditor.resizeImage(width, height) client-side method.

How the tool dialog works:
  • The dimensions are always retrieved from the Width and Height text-boxes, and the resizing happens when the Resize button is clicked.
  • The DropDownList contains a list of preset sizes, and the user can easily select from them. Upon selection, the values in the Width and Height inputs are changed.
  • The Percentage text-box can be used to specify new dimensions as a percentage from the original. It accepts values in the [0, 100%] interval. The values can be changed by using the Up and Down arrow keys.
  • There are two buttons that control the relationship between the Width and Height text-boxes: Constrain proportions and Swap dimensions. The first is used to lock the ratio between the width and height and keep the aspect ratio. By default the aspect ratio is preserved.
    The second gives the possibility to easily exchange the values of the width and height.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" Inherits="Telerik.Web.Examples.ImageEditor.Resize.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="../../common/styles.css" rel="stylesheet" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-medium">
        <telerik:RadImageEditor RenderMode="Lightweight" ID="RadImageEditor1" runat="server" ImageUrl="~/ImageEditor/images/resize.jpg" Width="100%">
            <Tools>
                <telerik:ImageEditorToolGroup>
                    <telerik:ImageEditorToolStrip CommandName="Undo">
                    </telerik:ImageEditorToolStrip>
                    <telerik:ImageEditorToolStrip CommandName="Redo">
                    </telerik:ImageEditorToolStrip>
                    <telerik:ImageEditorToolSeparator></telerik:ImageEditorToolSeparator>
                    <telerik:ImageEditorTool CommandName="Resize"></telerik:ImageEditorTool>
                </telerik:ImageEditorToolGroup>
            </Tools>
        </telerik:RadImageEditor>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance