(url)
| 19 | return False |
| 20 | |
| 21 | async 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 | |
| 42 | async def get_image_base64_string(image_uri): |
| 43 |
no test coverage detected