Skip to content

Remove fully opaque transparent channels #67

@BertrandBordage

Description

@BertrandBordage

As discussed in #66, it would be great to detect when a transparent channel is fully opaque and remove it before saving the new image.

This speeds up encoding while decreasing file size by around 10%.

Implementing this feature would essentially be:

from PIL import Image

image = Image.open(original_filename)
if image.mode == 'RGBA':
    colors = image.getchannel('A').getcolors()
    if len(colors) == 1 and colors[0][1] == 255:
        image = image.convert('RGB')
image.save(destination)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions