LineArt-线稿API使用文档
将之前写的线稿算法部署了一下
# 基本效果:
# 请求体
请求 URL:https://service.umb.ink/art/img
Method : POST
RequestForm: 将 img 作为 data 放在 FormData 中进行请求
{ | |
"file": fileData | |
} |
Response:处理完成后的线稿图像为二进制流 PNG 图片
# 示例
function postData() { | |
var xmlhttp; | |
xmlhttp=new XMLHttpRequest(); | |
var formData = new FormData(); | |
formData.append("file", data); | |
xmlhttp.open("POST",basePath+"/img",true); // 请求图片 | |
xmlhttp.responseType = "blob"; | |
xmlhttp.onload = function(){ | |
console.log(this); | |
if (this.status == 200) { | |
var blob = this.response; | |
var img = document.getElementById("result-image"); // 渲染到 img 标签 | |
img.onload = function(e) { | |
window.URL.revokeObjectURL(img.src); | |
}; | |
img.src = window.URL.createObjectURL(blob); | |
} | |
} | |
xmlhttp.send(formData); | |
} | |
// 赋值变量 | |
var basePath = getContextPath(); | |
// 获取项目路径 | |
function getContextPath() { | |
return "http://101.34.24.60:8008" | |
} |