标签:
简单JSP代码
图片加水银文字
try { String path = request.getRealPath("images\\01.jpg"); out.print(path); BufferedImage img = ImageIO.read(new FileInputStream(path)); out.print(img.getWidth()); out.print("<hr>"); out.print(img.getHeight()); Graphics g = img.getGraphics(); g.setColor(Color.YELLOW); g.drawString("Hello 13014577033", 100, 200); ImageIO.write(img, "jpg", new File("c:/t_01.jpg")); } catch (Exception e) { e.printStackTrace(); }
加logo
String path = request.getRealPath("images\\02.jpg"); String npath = request.getRealPath("images\\s02.jpg"); ImageUtil iu = new ImageUtil(path); iu.thumd(100,50,npath); String nnpath = request.getRealPath("images\\t02.jpg"); iu.txt("培训教育",30, nnpath); String logo = request.getRealPath("images\\fz.png"); String nn = request.getRealPath("images\\logot2.jpg"); iu.logo(logo, nn);
缩略图
try { String path = request.getRealPath("images\\01.jpg"); BufferedImage img = ImageIO.read(new FileInputStream(path)); int w = img.getWidth(); int h = img.getHeight(); int ww = 200; int hh = 150; BufferedImage nimg = new BufferedImage(ww,hh,BufferedImage.TYPE_INT_RGB); Graphics g = nimg.getGraphics(); g.drawImage(img, 0, 0, ww, hh, 0, 0, w, h, null); ImageIO.write(nimg, "jpg", new File("c:/s_01.jpg")); } catch (Exception e) { e.printStackTrace(); }
Java类
http://www.cnblogs.com/Dreamlu/p/4151256.html
标签:
原文地址:http://www.cnblogs.com/Dreamlu/p/4185463.html