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

Can I set the Min & Max Cropping Width & Height

3 Answers 164 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 23 Jan 2013, 03:22 PM
Hi,

Is it possible to set the minimum + maximum width and height of the crop box? I would like the user to be able to manually resize the crop box, but not bigger than 480px for the width or height. I am not concerned about aspect ratio.

Thanks in advance.

Kind regards,
Pierre

3 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 28 Jan 2013, 01:00 PM
Hi Pierre,

The desired functionality is not among the ImageEditor's built-in features, but you could achieve it by modifying the ImageEditor's Crop dialog. In order to do it you will need to:
 - Register the external dialogs of the ImageEditor - detailed information on how to do it is available here.
 - Modify the _setCropBoxConstraints() function of the Crop dialog in the following way:
_setCropBoxConstraints: function (bounds) {
    var image = this._imageEditor.getEditableImage();
    var zoomLevel = image.get_zoomLevel() / 100;
    bounds = new Sys.UI.Bounds(0, 0, parseInt(480 * zoomLevel), parseInt(480 * zoomLevel));
 
    this._cropBox.set_constraints(bounds || new Sys.UI.Bounds(0, 0, parseInt(image.get_width() * zoomLevel), parseInt(image.get_height() * zoomLevel)));
}

I hope this information was helpful for you.

All the best,
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
Martin Roussel
Top achievements
Rank 1
answered on 05 Dec 2013, 06:57 PM
Hi,

im trying to lock permanently the Crop size to 33px by 33px. Can you please show how to edit the ascx file to do so? I can fix the numbers in the textboxes but the crop area seems to stay the default size.

UPDATE: I figured a workaround so please ignore my previous question. My next issue is now I want to add some codebehind to the custom Crop.ascx to add some logic on control load, but im always getting this error when click the crop button:

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Could not load type '_Crop'. Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1…:15

 Is this supposed to work?

my ascx Control tag definition:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="Crop.ascx.cs" Inherits="_Crop" %>

my ascx.cs code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.ObjectModel;
 
    public partial class _Crop : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
    }


TIA
0
Vessy
Telerik team
answered on 10 Dec 2013, 12:41 PM
Hi Martin,

I am glad that you have managed to find a workaround for the first issue.

Regarding the code behind for the Crop dialog - the dialog itself has its Server-side functionality which doesn't have to be overriden. In order to add your own Server logic, you will need to create a custom user control, registered in the Crop.ascx file. Please, refer this KB for where the described approach is used: Displaying single upload control in the FileBrowser Upload manager

Regards,
Veselina Raykova
Telerik
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 the blog feed now.
Tags
ImageEditor
Asked by
Pierre
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Martin Roussel
Top achievements
Rank 1
Share this question
or