public BufferedImage rotateThumbnail(Image imageToRotate, int angle) {
	Image rotatedImage = new BufferedImage(imageToRotate.getHeight(null), imageToRotate.getWidth(null), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = (Graphics2D) rotatedImage.getGraphics();
        if(angle==1) {
            g2d.rotate(Math.toRadians(90.0));
            g2d.drawImage(imageToRotate, 0, -rotatedImage.getWidth(null), null);
        } if(angle==2) {
        } if(angle==3) {
            g2d.rotate(Math.toRadians(270.0));
            g2d.drawImage(imageToRotate, (int)(-rotatedImage.getWidth(null)*1.5), 0, null);
        }
        g2d.dispose();
	
	return (BufferedImage)rotatedImage;
    }