We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7922de2 commit d9f2d0fCopy full SHA for d9f2d0f
veadk/utils/misc.py
@@ -13,6 +13,7 @@
13
# limitations under the License.
14
15
import time
16
+import requests
17
18
19
def read_file(file_path):
@@ -28,6 +29,14 @@ def formatted_timestamp():
28
29
30
31
def read_png_to_bytes(png_path: str) -> bytes:
- with open(png_path, "rb") as f:
32
- data = f.read()
+ # Determine whether it is a local file or a network file
33
+ if png_path.startswith(("http://", "https://")):
34
+ # Network file: Download via URL and return bytes
35
+ response = requests.get(png_path)
36
+ response.raise_for_status() # Check if the HTTP request is successful
37
+ return response.content
38
+ else:
39
+ # Local file
40
+ with open(png_path, "rb") as f:
41
+ data = f.read()
42
return data
0 commit comments