Spaces:
Runtime error
Runtime error
chore: support webp mime type
Browse files
src/components/WebsocketDemo.tsx
CHANGED
@@ -75,7 +75,7 @@ export function WebsocketDemo() {
|
|
75 |
if (message?.event == "executing" && message?.data?.node == null)
|
76 |
setCurrentLog("done")
|
77 |
else if (message?.event == "live_status")
|
78 |
-
|
79 |
else if (message?.event == "elapsed_time")
|
80 |
setCurrentLog(`elapsed time: ${Math.ceil(message.data?.elapsed_time * 100) / 100}s`)
|
81 |
}
|
@@ -112,8 +112,13 @@ export function WebsocketDemo() {
|
|
112 |
break;
|
113 |
case 2:
|
114 |
imageMime = "image/png"
|
|
|
|
|
|
|
115 |
}
|
116 |
const blob = new Blob([buffer.slice(4)], { type: imageMime });
|
|
|
|
|
117 |
|
118 |
// const blob = new Blob([arrayBuffer], { type: 'image/png' }); // Assuming the image is a JPEG
|
119 |
const url = URL.createObjectURL(blob);
|
@@ -155,8 +160,8 @@ export function WebsocketDemo() {
|
|
155 |
<Badge variant={'outline'} className='w-fit'>Status: {status}</Badge>
|
156 |
<Badge variant={'outline'} className='w-fit'>
|
157 |
{currentLog}
|
158 |
-
{status == "connected"
|
159 |
-
{status == "ready"
|
160 |
</Badge>
|
161 |
</div>
|
162 |
<canvas ref={canvasRef} className='rounded-lg' width="1024" height="1024"></canvas>
|
|
|
75 |
if (message?.event == "executing" && message?.data?.node == null)
|
76 |
setCurrentLog("done")
|
77 |
else if (message?.event == "live_status")
|
78 |
+
setCurrentLog(`running - ${message.data?.current_node} ${(message.data.progress * 100).toFixed(2)}%`)
|
79 |
else if (message?.event == "elapsed_time")
|
80 |
setCurrentLog(`elapsed time: ${Math.ceil(message.data?.elapsed_time * 100) / 100}s`)
|
81 |
}
|
|
|
112 |
break;
|
113 |
case 2:
|
114 |
imageMime = "image/png"
|
115 |
+
break;
|
116 |
+
case 3:
|
117 |
+
imageMime = "image/webp"
|
118 |
}
|
119 |
const blob = new Blob([buffer.slice(4)], { type: imageMime });
|
120 |
+
const fileSize = blob.size;
|
121 |
+
console.log(`Received image size: ${(fileSize / 1024).toFixed(2)} KB`);
|
122 |
|
123 |
// const blob = new Blob([arrayBuffer], { type: 'image/png' }); // Assuming the image is a JPEG
|
124 |
const url = URL.createObjectURL(blob);
|
|
|
160 |
<Badge variant={'outline'} className='w-fit'>Status: {status}</Badge>
|
161 |
<Badge variant={'outline'} className='w-fit'>
|
162 |
{currentLog}
|
163 |
+
{status == "connected" && !currentLog && "stating comfy ui"}
|
164 |
+
{status == "ready" && !currentLog && " running"}
|
165 |
</Badge>
|
166 |
</div>
|
167 |
<canvas ref={canvasRef} className='rounded-lg' width="1024" height="1024"></canvas>
|