From 18fabdb7b2d2389968dd50a84ef3c535802247c9 Mon Sep 17 00:00:00 2001 From: LingXuanYin <3546599908@qq.com> Date: Mon, 4 Nov 2024 15:41:53 +0800 Subject: [PATCH 1/3] update code --- nodes/load_image_by_url.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nodes/load_image_by_url.py b/nodes/load_image_by_url.py index 035dfee..7079259 100644 --- a/nodes/load_image_by_url.py +++ b/nodes/load_image_by_url.py @@ -1,5 +1,6 @@ import hashlib import os +import io from PIL import Image, ImageSequence, ImageOps import numpy as np import torch @@ -41,6 +42,7 @@ class LoadImageByUrl: download_path = os.path.join(input_dir, self.filename()) with open(download_path, 'wb') as file: file.write(res.content) + return res.content else: raise ValueError(f"Failed to load image from {self.url}: {res.status_code} {res.text}") @@ -49,9 +51,9 @@ class LoadImageByUrl: input_dir = folder_paths.get_input_directory() image_path = os.path.join(input_dir, self.filename()) if cache == False or not os.path.isfile(image_path): - self.download_by_url() - - img = Image.open(image_path) + img = Image.open(io.BytesIO(self.download_by_url())) + else: + img = Image.open(image_path) output_images = [] for i in ImageSequence.Iterator(img): i = ImageOps.exif_transpose(i) From 7153ef7b0164caeacc7e677c70db45e0195d8642 Mon Sep 17 00:00:00 2001 From: LingXuanYin <3546599908@qq.com> Date: Mon, 4 Nov 2024 15:45:46 +0800 Subject: [PATCH 2/3] update exception if img file not found --- nodes/load_image_by_url.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nodes/load_image_by_url.py b/nodes/load_image_by_url.py index 7079259..9ef5d38 100644 --- a/nodes/load_image_by_url.py +++ b/nodes/load_image_by_url.py @@ -53,6 +53,8 @@ class LoadImageByUrl: if cache == False or not os.path.isfile(image_path): img = Image.open(io.BytesIO(self.download_by_url())) else: + if not os.path.isfile(image_path): + raise FileNotFoundError(f"Image file not found: {image_path}") img = Image.open(image_path) output_images = [] for i in ImageSequence.Iterator(img): From 79055476bde255be7a5dc19a0d768a21c7afd373 Mon Sep 17 00:00:00 2001 From: LingXuanYin <3546599908@qq.com> Date: Mon, 4 Nov 2024 15:52:27 +0800 Subject: [PATCH 3/3] Revert "update exception if img file not found" This reverts commit 7153ef7b0164caeacc7e677c70db45e0195d8642. --- nodes/load_image_by_url.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nodes/load_image_by_url.py b/nodes/load_image_by_url.py index 9ef5d38..7079259 100644 --- a/nodes/load_image_by_url.py +++ b/nodes/load_image_by_url.py @@ -53,8 +53,6 @@ class LoadImageByUrl: if cache == False or not os.path.isfile(image_path): img = Image.open(io.BytesIO(self.download_by_url())) else: - if not os.path.isfile(image_path): - raise FileNotFoundError(f"Image file not found: {image_path}") img = Image.open(image_path) output_images = [] for i in ImageSequence.Iterator(img):