{"id":18583176,"url":"https://github.com/gaoding-inc/gaoding-matting-editor-doc","last_synced_at":"2025-07-03T03:04:12.644Z","repository":{"id":128931830,"uuid":"140936710","full_name":"gaoding-inc/gaoding-matting-editor-doc","owner":"gaoding-inc","description":"Gaoding matting editor document","archived":false,"fork":false,"pushed_at":"2020-02-20T10:23:38.000Z","size":10,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-03T03:04:08.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaoding-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-14T10:22:25.000Z","updated_at":"2024-06-11T12:06:42.000Z","dependencies_parsed_at":"2023-07-03T20:15:21.230Z","dependency_job_id":null,"html_url":"https://github.com/gaoding-inc/gaoding-matting-editor-doc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gaoding-inc/gaoding-matting-editor-doc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaoding-inc%2Fgaoding-matting-editor-doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaoding-inc%2Fgaoding-matting-editor-doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaoding-inc%2Fgaoding-matting-editor-doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaoding-inc%2Fgaoding-matting-editor-doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaoding-inc","download_url":"https://codeload.github.com/gaoding-inc/gaoding-matting-editor-doc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaoding-inc%2Fgaoding-matting-editor-doc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263250596,"owners_count":23437288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T00:20:51.763Z","updated_at":"2025-07-03T03:04:12.613Z","avatar_url":"https://github.com/gaoding-inc.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 稿定抠图接入说明\n\n---\n\n## 前端 SDK\n\n前端 SDK 基于 Vue.js 实现，需要配合 Npm 以及 Webpack 打包才能嵌入项目；Npm 包参见：[@gaoding/matting-editor](https://www.npmjs.com/package/@gaoding/matting-editor)\n\n如果不熟悉 Vue.js 或者 Npm 可以使用示例中 `index.html`，推荐使用 Npm 方式引入。\n\n---\n\n## 后端 API\n\n### 签名算法\n\n\u003e 示例代码内有 Node.js 和 php 版本签名实现\n\n1. 设临时字符串为空， `let tmpStr = '';`\n2. 拼接 APPID， `tmpStr += APP_ID;`\n3. 拼接 HTTP Method (大写)， `tmpStr += '@' + 'GET';`\n4. 拼接 Request URI (不包含 host 和 protocol)， `tmpStr += '@' + '/templets';`\n5. 拼接 Query String，参数名按 ASCII 码从小到大排序（字典序，不需要 urlEncode）， `tmpStr += '@' + sortByASCII(query);`\n6. 拼接时间戳， `tmpStr += '@' + '1480486666';`\n7. 拼接 Request Body，如果内容为空忽略此步骤，对 body 做 JSON 序列化， `tmpStr += '@' + JSON.stringify(body);`\n8. 用 tmpStr 和 AppSecret 做 Hmac sha1 计算得到签名值（hex 全小写格式导出）， `let signature = sha1(tmpStr, APP_SECRET);`\n\n#### API_URL、APP_ID、 APP_SECRET\n\n外网 API_URL 为：`https://api.gaoding.com`\n\nAPP_ID 和 APP_SECRET 请联系稿定\b运营获取。\n\n#### 注意事项\n\n1. 所有数据均使用 utf-8 编码\n2. APPID，时间戳， 签名值分别使用 'X-Appid', 'X-Timestamp', 'X-Signature' 请求头发送\n3. Query String 区分大小写，且所以键值均不要做 URL Encode\n4. 各个数据块之间用 @ 隔开，Query String 为空时也要保留 @ 符号\n5. 时间戳精确到秒（10位），签名有效期为时间戳正负 5 分钟内\n6. 如果 Request Body 为空，忽略整个 body 的拼接\n7. JSON 序列化 Request Body 时，不要强转义字符，不要转为 unicode，例如 PHP: `$body_str = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);`\n8. 请求 API 时尽可能使用  `Content-type: application/json` 避免签名校验失败\n9. 如果遇到上传文件等二进制资源请求时，使用 `Content-Type: multipart/form-data`，同时二进制字段不参与签名计算\n\n\n### 创建抠图 - PostMattings\n\n\u003e POST /mattings\n\n#### 参数\n\n| 字段  | 类型 | 描述 |\n|---------|-----------|--------------------------------------|\n| scene | String  | **【可选】** 抠图场景 非稿定平台可选，稿定平台使用 url base字段 |\n| content | JSON |  抠图数据，详见 `content 结构示例`，如使用前端 SDK 接入，SDK 会自动处理数据  |\n| last_save_ip | String | 用户 IP |\n| last_ua | String | 用户 UA |\n\n#### 完整参数示例\n\n``` json\n{\n  \"content\": \"{\\\"sourceImage\\\":\\\"https://st-gdx.dancf.com/gaodingx/mattings/undefined/images/20180626-171051-2.png\\\",\\\"imageHeight\\\":0,\\\"imageWidth\\\":0,\\\"backgroundColor\\\":null,\\\"featheringRadius\\\":0,\\\"brushSize\\\":30,\\\"lines\\\":[]}\",\n  \"last_save_ip\": \"127.0.0.1\",\n  \"last_ua\": \"curl/1.7\"\n}\n```\n\n### 请求抠图 - PostMattingsIdImages\n\n\u003e POST /mattings/:id/images\n\n### 参数\n\n| 字段    | Type      | Description                          |\n|---------|-----------|--------------------------------------|\n| content | JSON | **【可选】** 抠图数据，详见 `content 结构示例`，如使用前端 SDK 接入，SDK 会自动处理数据 |\n| auto_fill_lines | Boolean |  是否自动填充笔画， 默认值: `true` |\n| last_save_ip | String |  用户 IP |\n| last_ua | String |  用户 UA |\n\n### 获取抠图详情 - GetMattingsId\n\n\u003e GET /mattings/:id\n\n### 更新抠图 - PutMattingsId\n\n\u003e PUT /mattings/:id\n\n#### 参数\n\n| 字段    | Type      | Description                          |\n|---------|-----------|--------------------------------------|\n| result_image | String | 抠图结果（需要 CDN地址） |\n| content | JSON | 抠图数据 |\n| last_save_ip | String | 用户 IP |\n| last_ua | String | 用户 UA |\n\n### 删除抠图 - DeleteMattingsId\n\n\u003e DELETE /mattings/:id\n\n----\n\n#### content 结构示例\n\n``` js\n{\n    \"sourceImage\": \"https://xxx.jpg\", // 图片 URL\n    \"imageWidth\": 100, // 图片宽度\n    \"imageHeight\": 100, // 图片高度\n    \"backgroundColor\": \"#FF0000\", // 输出时背景色，可以为 null\n    \"featheringRadius\": 0, // 羽化半径\n    \"brushSize\": 40 // 画笔大小\n    // 用户划线，线条只记录关键座标点，需要 UI 层面适配平滑度\n    \"lines\": [\n        // 保留线\n        {\n            \"action\": \"keep\",\n            \"size\": 40,\n            \"alpha\": 0.8,\n            \"color\": 0xff0000\n            \"points\": [\n                // x, y\n                0, 0,\n                1, 1\n            ]\n        },\n        // 剔除线\n        {\n            \"action\": \"drop\",\n            \"size\": 40,\n            \"alpha\": 0.8,\n            \"color\": 0x008800\n            \"points\": [\n                0, 0,\n                1, 1\n            ]\n        }\n    ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaoding-inc%2Fgaoding-matting-editor-doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaoding-inc%2Fgaoding-matting-editor-doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaoding-inc%2Fgaoding-matting-editor-doc/lists"}