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

Convert H&E thumbnail to RGB if RGBA or P mode #20

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

adamjtaylor
Copy link
Collaborator

In recent nextflow runs, I have noticed that some H&E images can present as RGBA (ie with transparency). This causes an error on saving the thumbnail.

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/PIL/JpegImagePlugin.py", line 639, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/tmp/nxf.OrYoBLjy6B/.command.sh", line 10, in
    thumb.save('miniature.jpg')
  File "/venv/lib/python3.10/site-packages/PIL/Image.py", line 2413, in save
    save_handler(self, fp, filename)
  File "/venv/lib/python3.10/site-packages/PIL/JpegImagePlugin.py", line 642, in _save
    raise OSError(msg) from e
OSError: cannot write mode RGBA as JPEG

This PR checks the thumbnail format and converts to RGB if RGBA or P format.

@adamjtaylor adamjtaylor changed the title Convert H&E thumbnail to RGB if RGB or P mode Convert H&E thumbnail to RGB if RGBA or P mode Aug 24, 2023
@thomasyu888 thomasyu888 merged commit 8b738da into main Sep 5, 2023
3 checks passed
@thomasyu888 thomasyu888 deleted the fix-he-thumbnail-color-mode branch September 5, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants