ssm框架更改图片分辨率

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38087648/article/details/79976661
@Override
    public Object ImageChange(String path,String fileName, int width, int height,HttpServletRequest request,String modify) throws Exception {
        // TODO Auto-generated method stub      
        BufferedInputStream in = new BufferedInputStream(new FileInputStream(path+fileName));
        // 字节流转图片对象
        Image bi = ImageIO.read(in);
        // 构建图片流
        BufferedImage tag = new BufferedImage(width , height , BufferedImage.TYPE_INT_RGB);
        // 绘制改变尺寸后的图
        boolean m = tag.getGraphics().drawImage(bi, 0, 0, width , height , null);
        System.out.println(m);
        // 输出流
        String ModifyfileName = fileName.substring(0, 16) + modify;
        String suffix = fileName.substring(fileName.lastIndexOf("."));
        ModifyfileName += suffix;
        File out = new File(path,ModifyfileName);
        out.createNewFile();
        boolean n = ImageIO.write(tag, "jpg", out);
        System.out.println(n);
        in.close();
        return ModifyfileName;
    }
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页