BufferedImage bufferedLeft = new BufferedImage(borderWidth,
(int)img.getScaledHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics2D g3 = bufferedLeft.createGraphics();
g3.setBackground(color);
g3.clearRect(0, 0, bufferedLeft.getWidth(),bufferedLeft.getHeight());
Image left = Image.getInstance(bufferedImage2ByteArray(bufferedLeft));
left.setAbsolutePosition(img.getAbsoluteX()-bufferedLeft.getWidth()/2, img.getAbsoluteY());
BufferedImage bufferedRight = new BufferedImage(borderWidth,
(int)img.getScaledHeight(),