Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live image without alpha channel #360

Closed
donkirkby opened this issue Jan 6, 2022 · 1 comment
Closed

Live image without alpha channel #360

donkirkby opened this issue Jan 6, 2022 · 1 comment

Comments

@donkirkby
Copy link
Owner

What I did

Tried to compare two images without alpha channels.

from PIL import Image
from space_tracer import LivePillowImage, LiveImageDiffer

a = LivePillowImage(Image.new('RGB', (100, 100)))
b = LivePillowImage(Image.new('RGB', (100, 100)))
differ = LiveImageDiffer()
differ.compare(a, b)

What happened

It complained about the missing alpha channel.

/home/don/.local/share/virtualenvs/svg-turtle-7kVEgXjr/bin/python /home/don/.config/JetBrains/PyCharm2021.3/scratches/scratch.py
Traceback (most recent call last):
  File "/home/don/.config/JetBrains/PyCharm2021.3/scratches/scratch.py", line 7, in <module>
    differ.compare(a, b)
  File "/home/don/.local/share/virtualenvs/svg-turtle-7kVEgXjr/lib/python3.9/site-packages/space_tracer/live_image.py", line 262, in compare
    diff_fill = self.compare_pixel(fill1, fill2, is_missing)
  File "/home/don/.local/share/virtualenvs/svg-turtle-7kVEgXjr/lib/python3.9/site-packages/space_tracer/live_image.py", line 334, in compare_pixel
    ar, ag, ab, aa = actual_pixel
ValueError: not enough values to unpack (expected 4, got 3)

What I wanted to happen

Make the alpha channel default to 255, the same as changing the code sample above to use mode 'RGBA'.

My environment

Describe the versions of everything you were using:

  • space_tracer 4.7.0
  • Ubuntu 20.04
  • Python 3.9.9

Analysis

Add a helper function to pad pixels to four channels, and call it in compare_pixel(). Think about grayscale images, as well.

@donkirkby
Copy link
Owner Author

In progress as PR #530.

@donkirkby donkirkby added this to the Near future milestone Mar 23, 2023
@donkirkby donkirkby modified the milestones: Near future, 4.10 Apr 8, 2023
donkirkby added a commit that referenced this issue Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant