get image
This commit is contained in:
@@ -3,6 +3,7 @@ import { upScaleAPIFormatJSON } from "../comfyJson/upscale";
|
||||
import axios from "axios";
|
||||
import { selectNodeFromApiJSONbyID } from "../utils/editComfyJson";
|
||||
import WebSocket from "ws";
|
||||
import { readJSONFile, saveJSONFile } from "../utils/jsonReader";
|
||||
const baseUrl = "http://47.108.92.176:20000";
|
||||
const baseWsUrl = "ws://47.108.92.176:20000";
|
||||
// const baseUrl = "http://localhost:8188";
|
||||
@@ -41,14 +42,21 @@ const UpscaleHandler: RequestHandler<any ,any> = async (ctx) => {
|
||||
if (type === "executed") {
|
||||
console.log(data.output);
|
||||
if (data.node === '47') {
|
||||
const filePath = './data.json';
|
||||
|
||||
readJSONFile(filePath)
|
||||
.then((data: any) => {
|
||||
console.log('读取的JSON数据:', data);
|
||||
// 修改对象
|
||||
data.push({ prompt: prompt, url: baseUrl + '/view?filename=' + data.output.images[0].filename, like: 0,index: data.length })
|
||||
// 保存回JSON文件
|
||||
return saveJSONFile(filePath, data);
|
||||
})
|
||||
|
||||
resolve(data.output.images[0].filename)
|
||||
}
|
||||
}
|
||||
} else if(event.data instanceof ArrayBuffer) {
|
||||
const blob = new Blob([event.data])// arraybuffer to blob
|
||||
let a = new FileReader();
|
||||
a.onload = function (e) { console.log('image/png;base64,'+ e.target!.result) }
|
||||
a.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user