feat: add support for gif upload
This commit is contained in:
parent
e65fa70503
commit
fce77b905c
@ -34,7 +34,7 @@ class ComfyUIDeployExternalImage:
|
|||||||
print("Fetching image from url: ", input_id)
|
print("Fetching image from url: ", input_id)
|
||||||
response = requests.get(input_id)
|
response = requests.get(input_id)
|
||||||
image = Image.open(BytesIO(response.content))
|
image = Image.open(BytesIO(response.content))
|
||||||
elif input_id.startswith('data:image/png;base64,'):
|
elif input_id.startswith('data:image/png;base64,') or input_id.startswith('data:image/jpeg;base64,') or input_id.startswith('data:image/jpg;base64,'):
|
||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
print("Decoding base64 image")
|
print("Decoding base64 image")
|
||||||
|
@ -34,7 +34,7 @@ class ComfyUIDeployExternalImageAlpha:
|
|||||||
print("Fetching image from url: ", input_id)
|
print("Fetching image from url: ", input_id)
|
||||||
response = requests.get(input_id)
|
response = requests.get(input_id)
|
||||||
image = Image.open(BytesIO(response.content))
|
image = Image.open(BytesIO(response.content))
|
||||||
elif input_id.startswith('data:image/png;base64,'):
|
elif input_id.startswith('data:image/png;base64,') or input_id.startswith('data:image/jpeg;base64,') or input_id.startswith('data:image/jpg;base64,'):
|
||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
print("Decoding base64 image")
|
print("Decoding base64 image")
|
||||||
|
@ -376,7 +376,7 @@ async def update_run_with_output(prompt_id, data, node_id=None):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
have_upload = 'images' in data or 'files' in data
|
have_upload = 'images' in data or 'files' in data or 'gifs' in data
|
||||||
|
|
||||||
print("\nhave_upload", have_upload, node_id)
|
print("\nhave_upload", have_upload, node_id)
|
||||||
|
|
||||||
@ -390,6 +390,10 @@ async def update_run_with_output(prompt_id, data, node_id=None):
|
|||||||
files = data.get('files', [])
|
files = data.get('files', [])
|
||||||
for file in files:
|
for file in files:
|
||||||
await upload_file(prompt_id, file.get("filename"), subfolder=file.get("subfolder"), type=file.get("type"), content_type=file.get("content_type", "image/png"))
|
await upload_file(prompt_id, file.get("filename"), subfolder=file.get("subfolder"), type=file.get("type"), content_type=file.get("content_type", "image/png"))
|
||||||
|
|
||||||
|
gifs = data.get('gifs', [])
|
||||||
|
for gif in gifs:
|
||||||
|
await upload_file(prompt_id, file.get("filename"), subfolder=file.get("subfolder"), type=file.get("type"), content_type=file.get("format", "image/gif"))
|
||||||
|
|
||||||
if have_upload:
|
if have_upload:
|
||||||
await update_file_status(prompt_id, data, False, node_id=node_id)
|
await update_file_status(prompt_id, data, False, node_id=node_id)
|
||||||
|
@ -5,7 +5,12 @@ export async function OutputRender(props: {
|
|||||||
run_id: string;
|
run_id: string;
|
||||||
filename: string;
|
filename: string;
|
||||||
}) {
|
}) {
|
||||||
if (props.filename.endsWith(".png")) {
|
if (
|
||||||
|
props.filename.endsWith(".png") ||
|
||||||
|
props.filename.endsWith(".gif") ||
|
||||||
|
props.filename.endsWith(".jpg") ||
|
||||||
|
props.filename.endsWith(".jpeg")
|
||||||
|
) {
|
||||||
const url = await getFileDownloadUrl(
|
const url = await getFileDownloadUrl(
|
||||||
`outputs/runs/${props.run_id}/${props.filename}`
|
`outputs/runs/${props.run_id}/${props.filename}`
|
||||||
);
|
);
|
||||||
@ -15,7 +20,7 @@ export async function OutputRender(props: {
|
|||||||
const url = await getFileDownloadUrl(
|
const url = await getFileDownloadUrl(
|
||||||
`outputs/runs/${props.run_id}/${props.filename}`
|
`outputs/runs/${props.run_id}/${props.filename}`
|
||||||
);
|
);
|
||||||
console.log(url);
|
// console.log(url);
|
||||||
|
|
||||||
return <DownloadButton filename={props.filename} href={url} />;
|
return <DownloadButton filename={props.filename} href={url} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user