图像审核接口
本接口除了支持自定义配置外，还对返回结果进行了总体的包装，按照用户在控制台中配置的规则直接返回是否合规，如果不合规则指出具体不合规的内容。
@param image 本地图片路径或图片url
@param type image参数类型：FILE或URL
@param options 可选参数
@return JSONObject
428712
public JSONObject imageCensorUserDefined(String image, EImgType type, HashMap<String, String> options) {
        if (type == EImgType.FILE) {
            try {
                byte[] imgData = Util.readFileByBytes(image);
                return imageCensorUserDefined(imgData, options);
            } catch (IOException e) {
                return AipError.IMAGE_READ_ERROR.toJsonResult();
            }
        }

        // url
        AipRequest request = new AipRequest();

        request.addBody("imgUrl", image);

        return imageCensorUserDefinedHelper(request, options);
    }
1356346
public Optional<MapperInstance> getDeserializer( JType type ) {
        return Optional.fromNullable( deserializers.get( type.getQualifiedSourceName() ) );
    }
10675
public static boolean write(Image image, String imageType, ImageOutputStream destImageStream, float quality) throws IORuntimeException {
		if (StrUtil.isBlank(imageType)) {
			imageType = IMAGE_TYPE_JPG;
		}

		final ImageWriter writer = getWriter(image, imageType);
		return write(toBufferedImage(image, imageType), writer, destImageStream, quality);
	}
120852
public static <T> T readUrlAsObject(String url, Class<T> type) {
		String contents = getUrlContents(url);
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping();

		try {
			return mapper.readValue(contents, type);
		} catch (IOException e) {
			JK.throww(e);
			return null;
		}
	}
803383
public static BufferedImage toBufferedImage(Image image, String imageType) {
		BufferedImage bufferedImage;
		if (false == imageType.equalsIgnoreCase(IMAGE_TYPE_PNG)) {
			// 当目标为非PNG类图片时，源图片统一转换为RGB格式
			if (image instanceof BufferedImage) {
				bufferedImage = (BufferedImage) image;
				if (BufferedImage.TYPE_INT_RGB != bufferedImage.getType()) {
					bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
				}
			} else {
				bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
			}
		} else {
			bufferedImage = toBufferedImage(image);
		}
		return bufferedImage;
	}
1325688
public static boolean write(Image image, String imageType, ImageOutputStream destImageStream) throws IORuntimeException {
		return write(image, imageType, destImageStream, 1);
	}
292030
@NonNull
    public static Artwork fromJson(@NonNull JSONObject jsonObject) {
        @SuppressWarnings("WrongConstant") // Assume the KEY_META_FONT is valid
        Builder builder = new Builder()
                .title(jsonObject.optString(KEY_TITLE))
                .byline(jsonObject.optString(KEY_BYLINE))
                .attribution(jsonObject.optString(KEY_ATTRIBUTION))
                .token(jsonObject.optString(KEY_TOKEN))
                .metaFont(jsonObject.optString(KEY_META_FONT))
                .dateAdded(new Date(jsonObject.optLong(KEY_DATE_ADDED, 0)));

        String componentName = jsonObject.optString(KEY_COMPONENT_NAME);
        if (!TextUtils.isEmpty(componentName)) {
            builder.componentName(ComponentName.unflattenFromString(componentName));
        }

        String imageUri = jsonObject.optString(KEY_IMAGE_URI);
        if (!TextUtils.isEmpty(imageUri)) {
            builder.imageUri(Uri.parse(imageUri));
        }

        try {
            String viewIntent = jsonObject.optString(KEY_VIEW_INTENT);
            String detailsUri = jsonObject.optString(KEY_DETAILS_URI);
            if (!TextUtils.isEmpty(viewIntent)) {
                builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME));
            } else if (!TextUtils.isEmpty(detailsUri)) {
                builder.viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(detailsUri)));
            }
        } catch (URISyntaxException ignored) {
        }

        return builder.build();
    }
152556
Object fromJson(OpenType type, String json) {
        return converters.getToOpenTypeConverter().convertToObject(type,json);
    }
357703
public JSONObject sendImageRequest(String url, byte[] image, HashMap<String, Object> options) {
        AipRequest request = new AipRequest();
        preOperation(request);
        String content = Base64Util.encode(image);
        request.addBody("image", content);
        if (options != null) {
            request.addBody(options);
        }
        request.setUri(url);
        request.addHeader(Headers.CONTENT_ENCODING,
                HttpCharacterEncoding.ENCODE_UTF8);
        request.addHeader(Headers.CONTENT_TYPE, HttpContentType.JSON_DATA);
        request.setBodyFormat(EBodyFormat.RAW_JSON);
        postOperation(request);
        return requestServer(request);
    }
1101316
public static String toBase64(Image image, String imageType) {
		final ByteArrayOutputStream out = new ByteArrayOutputStream();
		write(image, imageType, out);
		return Base64.encode(out.toByteArray());
	}
634584
public JSONObject dehaze(byte[] image, HashMap<String, String> options) {
        AipRequest request = new AipRequest();
        preOperation(request);
        
        String base64Content = Base64Util.encode(image);
        request.addBody("image", base64Content);
        if (options != null) {
            request.addBody(options);
        }
        request.setUri(ImageProcessConsts.DEHAZE);
        postOperation(request);
        return requestServer(request);
    }
350151
public JSONObject animalDetect(byte[] image, HashMap<String, String> options) {
        AipRequest request = new AipRequest();
        preOperation(request);
        
        String base64Content = Base64Util.encode(image);
        request.addBody("image", base64Content);
        if (options != null) {
            request.addBody(options);
        }
        request.setUri(ImageClassifyConsts.ANIMAL_DETECT);
        postOperation(request);
        return requestServer(request);
    }
1078257
private JSONObject getImageKeyword(final JSONArray imageKeywords, final int index) {
    JSONObject object = new JSONObject();
    try {
      object = (JSONObject) imageKeywords.get(index);
    }
    catch(JSONException e) {
      e.printStackTrace();
    }
    return object;
  }
1038944
public function serializeImageToJson(JsonSerializationVisitor $visitor, Image $image, array $type, Context $context)
    {
        $type['name'] = 'array';

        return $visitor->visitArray([
            'id' => $image->getId(),
            'url' => $this->imageManager->filePathToWebPath($image->getPath())
        ], $type, $context);
    }
807072
public static ImageOption http() {
    return new ImageOption("http", "") {
      @Override public String apply(String url) {
        if (url.startsWith("//")) {
          return "http:" + url;
        } else {
          return url;
        }
      }
    };
  }
315684
public com.google.protobuf.ByteString
      getImageBytes() {
    java.lang.Object ref = image_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      image_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
865194
public static String toInlineImage(@javax.annotation.Nonnull final LabeledObject<BufferedImage> img) {
    @javax.annotation.Nonnull final ByteArrayOutputStream b = new ByteArrayOutputStream();
    try {
      ImageIO.write(img.data, "PNG", b);
    } catch (@javax.annotation.Nonnull final RuntimeException e) {
      throw e;
    } catch (@javax.annotation.Nonnull final Exception e) {
      throw new RuntimeException(e);
    }
    final byte[] byteArray = b.toByteArray();
    final String encode = Base64.getEncoder().encodeToString(byteArray);
    return "<img src=\"data:image/png;base64," + encode + "\" alt=\"" + img.label + "\" />";
  }