Welcome Guest! You need to login or register to make posts.



Go to last post Go to first unread
#1 Posted : Monday, March 12, 2012 2:58:06 AM(UTC)

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)

“The first step I need is to resize images to width’ px width and then automatically crop it to height’’ px height (please see picture with details). What I should do to approach it?”


Automatic Cropping section describes how to crop images automatically. In this case, images will be cropped first and then converted with a specified mode. However, sometimes user needs to crop already converted image which has width/height different from original ones. Unfortunately, this way is not possible for Image Uploader, but it can be easy bypassed.

To approach it, please use the following way:
  • crop each original image by height divided by width’/height’’ ratio; width of original image should not be changed. Here we use BeforeUpload and BeforePackageUpload events – I will post the script below.
  • resize cropped image.
Here is the code of the events:
width = [];
height = [];
imageCenterX = [];
imageCenterY = [];
cropWidth = [];
cropHeight = [];
cropBounds = [];
k = [];
function beforeUploadHandler(){
  ratio = width’ / height’’;
  var count = $au.uploader('Uploader1').files().count();
  for (var i = 0; i < count; i++) {
    var $file = $au.uploader('Uploader1').files().get(i);
    width[i] = $file.width();
    height[i] = $file.height();
    cropWidth[i] = $file.width();
    cropHeight[i] = cropWidth[i] / ratio;
    imageCenterX[i] = $file.width() / 2;
    imageCenterY[i] = $file.height() / 2;
    cropBounds[i] = [(imageCenterX[i] - cropWidth[i]/2),(imageCenterY[i] - cropHeight[i]/2), cropWidth[i], cropHeight[i]];
    k[i] = i;
function beforePackageUploadHandler(){
  for (var i = 0; i < k.length; i++) {
    var $file = $au.uploader('Uploader1').files().get(i);

Edited by user Monday, March 12, 2012 6:58:55 PM(UTC)  | Reason: Not specified

Dmitry.Obukhov attached the following image(s):
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.