INNER CODE UNIT · Python

image_data

McDevon/taxman-engine · Scripts/generate_sprite_sheet.py:18

def image_data(path):
    img = Image.open(path)
    if img.mode == 'P':
        img = img.convert('RGBA')
    has_alpha = img.mode == 'RGBA'
    is_monochrome = img.mode == 'L'
    is_monochrome_alpha = img.mode == 'LA'
    width, height = img.size

    if has_alpha:
        red, _, _, alpha = img.split()
        a = alpha.load()
        r = red.load()
    elif is_monochrome:
        a = None
        r = img.load()
    elif is_monochrome_alpha:
        red, alpha = img.split()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…