java 生成图片
2种方式
//BufferedImage pictureDest = imageService.makePicture(inv, name, bgPicture);
ImageIO.write(image, "jpg", inv.getResponse().getOutputStream());
BufferedImage image = new BufferedImage(334, 448, BufferedImage.TYPE_3BYTE_BGR);
Graphics gra = image.getGraphics();
BufferedImage bg = ImageIO.read(new URL(bgPicture));
gra.drawImage(bg, 0, 0, null);
gra.setFont(new Font("宋体", Font.PLAIN, 32));
gra.drawString(name, 30, 50);
2
String pictureDir = realPath + "people/nToWeibo/1.jpg";
String webFilePath = "people/real.jpg";
String outputFile = realPath + webFilePath;
ImageInfo info = new ImageInfo(pictureDir);
MagickImage image = new MagickImage(info);
DrawInfo drawinfo = new DrawInfo(new ImageInfo());
drawinfo.setFont(realPath + "people/wqy-zenhei.ttc");
drawinfo.setText("中国人民共和国");
drawinfo.setGeometry("+30+100");
drawinfo.setBorderColor(PixelPacket.queryColorDatabase("black"));
image.annotateImage(drawinfo);
image.setFileName(outputFile);
image.writeImage(new ImageInfo());
image.destroyImages();
return "@:" + webFilePath;