File size: 316 Bytes
774fe36
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import io
from PIL import Image


def extract_png_info(image_bytes: bytes) -> dict:
    """Extract text metadata from PNG."""
    info = {}
    try:
        img = Image.open(io.BytesIO(image_bytes))
        if hasattr(img, 'text'):
            info = dict(img.text)
    except Exception:
        pass
    return info