Rank: Member
Groups: Member
Joined: 12/6/2010(UTC) Posts: 20
Thanks: 6 times
|
Hi, i have the next code to crop a image automatically: Code:
converters: [
{ mode: '*.*=Thumbnail', thumbnailWidth: 900, thumbnailHeight: 318, thumbnailApplyCrop: true, thumbnailFitMode: 'Width' },
{ mode: '*.*=Thumbnail', thumbnailWidth: 120, thumbnailHeight: 80, thumbnailApplyCrop: true, thumbnailFitMode: 'Width' }
],
events: { beforeUpload: beforeUploadHandler },
This works fine, but i need to crop before resizing, the first step i need is resize pic to 900 px width and then crop it. What i must to do? Thanks!
|
|
|
|
Rank: Advanced Member
Groups: Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hello Juan,
Your request confused me a bit. You said: “i need to crop before resizing”. Then: “the first step i need is resize pic to 900 px width and then crop it”. Could you please clarify this? Actually, the uploader first crops a source image, and then resizes it.
Also, please share the code of BeforeUpload event. |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
1 user thanked Dmitry.Obukhov for this useful post.
|
|
|
Rank: Member
Groups: Member
Joined: 12/6/2010(UTC) Posts: 20
Thanks: 6 times
|
Sorry, im stupid... I mean I need resize the pic first to 900px width, and the second step crop it 900px x 318px. Actually imageuploader crop image and then resize, but this is not useful to me. The BeforeUpload code is same code as documentation sample: Code:
function beforeUploadHandler(){
var cropWidth = 900;
var cropHeight = 318;
var count = $au.uploader('Uploader1').files().count();
for (var i=0; i < count; i++) {
var $file = $au.uploader('Uploader1').files().get(i);
var imageCenterX = $file.width() / 2;
var imageCenterY = $file.height() / 2;
var cropBounds = [(imageCenterX - cropWidth/2),
(imageCenterY - cropHeight/2), cropWidth, cropHeight];
$file.cropBounds(cropBounds);
}
}
I hope you can help me.
|
|
|
|
Rank: Advanced Member
Groups: Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Juan, Thank you for these details. As I wrote the uploader crops images first and then resizes it. However, there is simple workaround. If I understand rightly you need to get resized image by width to 900 px and then cropped by height to 318 px. Please look at my attached picture. If it is so, I offer the following way: - crop each original image by height divided by 900/318; width of original image should not be changed. To approach it we use BeforeUpload and BeforePackageUpload events – I will post the script below.
- resize cropped image. We get 900x318 image as a result.
Here is the code of the events: Code:
width = [];
height = [];
imageCenterX = [];
imageCenterY = [];
cropWidth = [];
cropHeight = [];
cropBounds = [];
k = [];
function beforeUploadHandler(){
ratio = 900 / 318;
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);
$file.cropBounds(cropBounds[i]);
}
}
Please do not forget to specify BeforePackageUpload event in the settings of the uploader: Code:
events: {
beforeUpload: beforeUploadHandler,
beforePackageUpload: beforePackageUploadHandler,
},
If you have any additional questions please feel free to let me know. Edited by user Monday, March 12, 2012 1:10:36 AM(UTC)
| Reason: Not specified Dmitry.Obukhov attached the following image(s): |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
1 user thanked Dmitry.Obukhov for this useful post.
|
|
|
Rank: Member
Groups: Member
Joined: 12/6/2010(UTC) Posts: 20
Thanks: 6 times
|
Was the solution! Thanks!
I need to purchase a new license of ImageUploader Express, you will have news soon!
Thanks again Dmitry!
|
|
|
|
Rank: Advanced Member
Groups: Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hello, I am glad that this problem has been resolved. As for purchasing new update of the uploader please contact our sales team: sales@aurigma.comIf you have any additional technical questions or problems please feel free to let me know. |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
1 user thanked Dmitry.Obukhov for this useful post.
|
|
|
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.