Skip to content

Bug: Transparency is lost when comparing images with alpha channels (e.g., PNGs) #27

Description

@left-no-crumbz

Description:

Hi there,

I've noticed that when using streamlit-image-comparison to compare images that have transparency (like PNG files with an alpha channel), the transparency information seems to be lost in the displayed comparison.

Problem:

Transparent areas in the source images are rendered as opaque (often solid black) within the comparison component. This makes it difficult to accurately compare images where transparency is important.

Steps to Reproduce:

  1. Create a simple Streamlit app.
  2. Load one image that has transparency, and another that doesn't. This makes the issue very clear. (You can use the example image attached to this issue).
  3. Use the image_comparison function to display them.

Expected Behavior:

The streamlit-image-comparison component should display the images while preserving their transparency. Transparent areas should remain transparent, showing the underlying background color.

Actual Behavior:

The transparent areas are rendered as opaque (often black), as seen in the comparison view. The standard st.image function correctly displays the transparency for the same uploaded image.

Image

The image I attached when creating this issue demonstrates the problem. The transparent background is lost in the comparison.

Environment:

  • streamlit-image-comparison version: 0.0.4
  • streamlit version: 1.44.1
  • Python version: 3.12.0
  • OS: Windows 10
  • Browser: Brave (Chromium)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions