Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to Resize image file in Java Webdynpro


I have a requirement, where user can upload his/her image from his desktop into webdynpro java screen. and suppose he uploads his image and when he refreshed the page or again logins, he should see his image which he uploaded last time.

So what I am doing is when user is uploading his image, first I am saving his image into some folder in portal server, and I am reding that image from that folder.

for this I have created, 1 folder in portal server with name Image, and I am saving all the images which user is uploading.

This is the code I am using.

IWDResource resource = null;

WDWebResourceType resourceType = null;

File fp = new File("/usr/sap/Image/"UserID".jpg");

FileInputStream fis = new FileInputStream(fp);

BufferedInputStream bis = new BufferedInputStream(fis);

resourceType =



resource = WDResourceFactory.createResource(bis, UserID+".jpg",resourceType, true);







wdComponentAPI.getMessageManager().reportSuccess("Please upload your passport size photograph here");


My question is : How I can resize the pic size before saving to Image folder, that is suppose user is uploading 1 MB size photo, but i want to resize it to say 15 KB only before saving to Image folder in portal server. I want to restrict all the image size to 15 KB only.

How to do that in the above code? please help..Thanks..

Former Member
Not what you were looking for? View more on this topic or Ask a question