-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
imsave should preserve alpha channel #1956
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
@@ -1273,7 +1273,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, | |||
fig = Figure(figsize=figsize, dpi=dpi, frameon=False) | |||
canvas = FigureCanvas(fig) | |||
im = fig.figimage(arr, cmap=cmap, vmin=vmin, vmax=vmax, origin=origin) | |||
fig.savefig(fname, dpi=dpi, format=format) | |||
fig.patch.set_alpha(0) |
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.
Does the transparent
kwarg on savefig do the same thing? (http://matplotlib.org/faq/howto_faq.html#save-transparent-figures)
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.
You're right, it does. (Silly me, I'd forgotten about that option.)
I've updated the branch to use that instead.
Ah. Unfortunately the travis-ci instance has this test failing: https://s3.amazonaws.com/archive.travis-ci.org/jobs/6792238/log.txt |
That's because #1868 hasn't been merged. (This hits the same problem that that fixes.) On my test branch with both patches applied, the test passes. |
Doh! Time to go home - its been a long day 😄 |
Oh, oops. I think I half-botched a rebase of this branch, but the overall diff is still correct. |
I think we only need a single commit for this change, so would you mind going ahead and squashing your changes? if its more trouble than its worth, don't worry about it though. |
Done (and managed to do it right this time.) |
👍 -- @pelson: I leave it to you to push the green button since you've been following all this closer than I. |
Imsave now preserves the alpha channel.
While looking at test_image, I noticed the comment that
imsave
was flattening alpha channel data. I figured this was related to #1868 (it is, partially), and decided to fix it.I've updated the test to reflect that an imsave/imread round-trip should now preserve full RGBA data to within 1/255.
Passing the test, however, requires that the patches from #1868 also be applied.