java--判断图片的像素

    /**
     * 图片像素判断
     *
     * @param imgPath 图片地址
     * @return
     * @throws IOException
     */
    public static boolean judgeImgPixel(String imgPath) throws IOException {
        BufferedImage bi = ImageIO.read(new FileInputStream(imgPath));
        int width = bi.getWidth();
        int height = bi.getHeight();
        if (width < 128 || height < 128 || width > 4096 || height > 4096) {
            return false;
        }
        return true;
    }
posted @ 2020-12-28 16:59  vaen  阅读(681)  评论(0)    收藏  举报