public static Image scaleImage(Image inputImg, int maxWidth, int maxHeight)
	{
		int imgWidth = inputImg.getWidth(null);
		int imgHeight = inputImg.getHeight(null);
		
    	if(imgWidth > maxWidth)
    	{
    		imgHeight = (imgHeight * maxWidth) / imgWidth;
    		imgWidth = maxWidth;
    	}
    	
    	if(imgHeight > maxHeight)
    	{
    		imgWidth = (imgWidth * maxHeight) / imgHeight;
    		imgHeight = maxHeight;
    	}        	
    	
    	if(imgWidth != inputImg.getWidth(null) || imgHeight != inputImg.getHeight(null))
    		return inputImg.getScaledInstance(imgWidth, imgHeight, Image.SCALE_SMOOTH);
    	else
    		return inputImg;
	}