(path: Union[str, Path])
| 9 | |
| 10 | |
| 11 | async def load_image_async(path: Union[str, Path]) -> Image.Image: |
| 12 | try: |
| 13 | async with aiofiles.open(path, "rb") as f: |
| 14 | data = await f.read() |
| 15 | |
| 16 | return await asyncio.to_thread(lambda: Image.open(io.BytesIO(data)).convert("RGB")) |
| 17 | except Exception as e: |
| 18 | logger.error(f"Failed to load image from {path}: {e}") |
| 19 | raise |
| 20 | |
| 21 | |
| 22 | async def save_video_async(video_path: Union[str, Path], video_data: bytes): |