Fetch image from URL.
(url: str)
| 117 | |
| 118 | |
| 119 | def fetch_image_bytes(url: str) -> bytes: |
| 120 | """Fetch image from URL.""" |
| 121 | try: |
| 122 | req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) |
| 123 | resp = urllib.request.urlopen(req, timeout=30) |
| 124 | return resp.read() |
| 125 | except Exception as e: |
| 126 | log(f"Image fetch failed: {e}") |
| 127 | return b"" |