We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

resize image with UploaderComponent

Thread ID:

Created:

Updated:

Platform:

Replies:

145650 Jul 2,2019 10:13 AM UTC Jul 3,2019 05:18 PM UTC React - EJ 2 1
loading
Tags: Uploader
TOKO FIDELE
Asked On July 2, 2019 10:13 AM UTC


hello, I use the component> </ UploaderComponent>  to upload my images, the problem is that the images have different sizes in the display. I would like to validate my images before uploading. the images, therefore, the dimmensions are greater than (height 400px and width 500px) are resized at (height 400px and width 500px) and those with dimensions less than (height 400px and width 500px) are rejected.
thank you

Prince Oliver [Syncfusion]
Replied On July 3, 2019 05:18 PM UTC

Hi Toko, 

Thank you for contacting us. 

Query 1: would like to validate my images before uploading. the images, therefore, the dimmensions are greater than (height 400px and width 500px) are resized at (height 400px and width 500px) 

You can achieve this query by using the below UG Documentation. Please find the UG Documentation link 

Query 2: those with dimensions less than (height 400px and width 500px) are rejected 

As per your requirement, we have abort the those files with the specified height and width. Please find the below code snippet 

[index.js] 
onUpload(args){ 
    var flag = false; 
    var image = new Image(); 
    image.src = window.URL.createObjectURL(args.fileData.rawFile); 
    image.onload = function () { 
        if (this.naturalHeight < 300 && this.naturalWidth < 375) { 
            flag = true; 
        } 
 
        if (flag) { 
            args.currentRequest.abort() 
        } 
    } 
} 


Let us know if you need any further assistance on this. 

Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon