public static byte[] getImageToByteArr(Image src) throws IOException {
int width = (int)(src.getWidth(null));
int height = (int)(src.getHeight(null));
//将设置好的图片追加到BufferedImage中
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = bufferedImage.createGraphics();
//重构图片
graphics.drawImage(src, 0, 0, width, height, null);
ByteArrayOutputStream bs =new ByteArrayOutputStream();
ImageOutputStream imOut;
imOut = ImageIO.createImageOutputStream(bs);
ImageIO.write(bufferedImage,"jpg",imOut);
return bs.toByteArray();
}