Decode PNG bytes to PIL Image.
(path_and_bytes)
| 291 | |
| 292 | # Step 4: Decode each unique image ONCE (avoid decoding same image N times) |
| 293 | def _decode_one(path_and_bytes): |
| 294 | """Decode PNG bytes to PIL Image.""" |
| 295 | path, raw_bytes = path_and_bytes |
| 296 | try: |
| 297 | img_pil = Image.open(io.BytesIO(raw_bytes)) |
| 298 | img_pil.load() |
| 299 | return path, img_pil |
| 300 | except Exception: |
| 301 | return path, None |
| 302 | |
| 303 | decode_items = [(p, b) for p, b in img_bytes_map.items() if b is not None] |
| 304 | img_pil_map = {} |