private Image scaleImage(URL imageURL,int width, int height) {
try {
Image scaledBimg = null;
ContentRepositoryRegistry registry = ContentRepositoryRegistry.getInstance();
ContentRepository cr = registry.getRepository(LoginManager.getPrimary());
String[] urls = imageURL.toString().split("/");
String fname = urls[urls.length-1];
String userName = urls[3];
ContentCollection user = cr.getUserRoot(userName);
ContentResource res = (ContentResource) user.getChild(fname);
BufferedImage bimg = ImageIO.read(res.getInputStream());
if(bimg.getWidth()>width || bimg.getHeight()>height) {