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. Image for the cookie policy date
close icon

resize image with UploaderComponent


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

1 Reply

PO Prince Oliver Syncfusion Team 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 


Loader.
Live Chat Icon For mobile
Up arrow icon