-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
proposed fix for transparency issue #27173 #27406
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
@JakobRing @Wuzuw do you have any interest in coming back to this PR? It seems reasonable but needs a bit of work (use |
@@ -1079,7 +1079,11 @@ def func(current_frame: int, total_frames: int) -> Any | |||
|
|||
def _pre_composite_to_white(color): | |||
r, g, b, a = mcolors.to_rgba(color) | |||
return a * np.array([r, g, b]) + 1 - a | |||
if type(writer) == PillowWriter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be addressed
if type(writer) == PillowWriter: | |
if isinstance(writer, PillowWriter): |
@@ -1079,7 +1079,11 @@ def func(current_frame: int, total_frames: int) -> Any | |||
|
|||
def _pre_composite_to_white(color): | |||
r, g, b, a = mcolors.to_rgba(color) | |||
return a * np.array([r, g, b]) + 1 - a | |||
if type(writer) == PillowWriter: | |||
print("no true transparency using pillow") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print("no true transparency using pillow") |
print("no true transparency using pillow") | ||
return a * np.array([r, g, b]) + 1 - a | ||
else: | ||
return np.array([r, g, b, a]) | ||
|
||
savefig_kwargs['facecolor'] = _pre_composite_to_white(facecolor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the name of the internal function _pre_composite_to_white
, I think it makes more sense to put the conditional around this bit of code (and just not call the function if we don't need it) rather than make the function actually do "maybe pre-composite with white based on the type of something in my outer scope".
Another question here is that is it better to have a "known bad" list or a "known good" list? I'm inclined to think it should be "known good" and the check should probably be more through than just the type of the writer (re-skimming the linked issues I think it depends on the encoding used not just the program). |
We probably also need to add a keyword arguement to |
This is superseded by #29024 . Thank you for your work @JakobRing and hopefully we will hear from you again. |
Suggestion by @Wuzuw, another friend and me for the closing of #27173
We suggest to check if the pillowwriter is used. If so we use the fix by @tacaswell in #19040 and if ffmpeg is used we use the standard rgba-values because ffmpeg can deal with transparency.