首页 > 技术文章 > java--判断图片的像素

vaen 2020-12-28 16:59 原文

    /**
     * 图片像素判断
     *
     * @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;
    }

推荐阅读