public static BufferedImage concatenateHorizontal(BufferedImage...im) throws ImagesHeightNotAlignedException {
		if (im==null || im.length==0) {
			return null;
		}
		if (im.length==1) {
			return im[0];
		}
		
		int height = im[0].getHeight();
		int totalWidth = 0;
		for (BufferedImage i : im) {
			int currentHeight = i.getHeight();
			if (currentHeight != height) {
				throw new ImagesHeightNotAlignedException();
			}
			totalWidth += i.getWidth();
		}
		
		BufferedImage resultImage = new BufferedImage(totalWidth, height, BufferedImage.TYPE_INT_BGR);
		
		int cumulativeWidth = 0;
		for (int i = 0;i < im.length;i++) {
			for (int j = 0;j < im[i].getWidth();j++) {
				for (int k = 0;k < height;k++) {
					resultImage.setRGB(j+cumulativeWidth, k, im[i].getRGB(j, k));
				}
			}
			cumulativeWidth += im[i].getWidth();
		}
		
		return resultImage;
	}