码迷,mamicode.com
首页 > 其他好文 > 详细

图片加水印文字,logo。生成缩略图

时间:2014-12-25 21:45:50      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

简单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

图片加水印文字,logo。生成缩略图

标签:

原文地址:http://www.cnblogs.com/Dreamlu/p/4185463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!