MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / fetch_image_format

Function fetch_image_format

plugin/app/service/image_load.py:21–40  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

19 return False
20
21async def fetch_image_format(url):
22
23 # Image in local file system
24 if image_url_is_on_localhost(url):
25
26 local_file_path = CONFIG.PATH_TO_VOLUME + "/imgs/" + url.split("/imgs/")[1]
27 with open(local_file_path, "rb") as image_file:
28 image_bytes = image_file.read()
29 image = Image.open(BytesIO(image_bytes))
30 return image.format
31
32 async with aiohttp.ClientSession() as session:
33 async with session.get(url) as response:
34 response.raise_for_status() # Ensure the request was successful
35 # Read the response content as bytes
36 image_bytes = await response.read()
37 # Load the image into a PIL Image object
38 image = Image.open(BytesIO(image_bytes))
39 # Output the format of the image
40 return image.format
41
42async def get_image_base64_string(image_uri):
43

Callers 4

executeMethod · 0.90
executeMethod · 0.90
construct_image_dataFunction · 0.90
construct_image_dataFunction · 0.90

Calls 2

getMethod · 0.45

Tested by

no test coverage detected