code: private static BufferedImage encodeImg(BufferedImage desImg, Float quality) {
          ByteArrayOutputStream baos = null;
          ByteArrayInputStream bais = null;
          BufferedImage bufferedImage = null;
          try {
              if (quality != null) {
                  if (quality > 1.0 || quality < 0.0) {
                      throw new Exception("quality参数指定值不正确");
                  }
              }
              baos = new ByteArrayOutputStream();
              //图片采用JPEG格式编码
              JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(baos);
              if (quality != null) {
                  //编码参数
                  JPEGEncodeParam jep = JPEGCodec.getDefaultJPEGEncodeParam(desImg);
                  //设置压缩质量
                  jep.setQuality(quality, true);
                  //开始编码并输出
                  encoder.encode(desImg, jep);
              } else {
                  //开始编码并输出
                  encoder.encode(desImg);
              }
  
              bais = new ByteArrayInputStream(baos.toByteArray());
              bufferedImage = ImageIO.read(bais);
  
          } catch (Exception e) {
              throw new RuntimeException(e);
          } finally {
              CommonUtils.closeIOStream(bais, baos);
          }
  
          return bufferedImage;
      }
docs: 采用JPEG编码图片，并生成BufferedImage对象返回
  
  @param desImg  编码源图片
  @param quality 编码质量
  @return 返回编码后的BufferedImage对象