Repository navigation
Check origin when saving image to PNG - #7731
Conversation
| def write_png(self, fname): | ||
| """Write the image to png file with fname""" | ||
| if self.origin == 'upper': | ||
| self._A = self._A[::-1] |
There was a problem hiding this comment.
You should not overwrite self._A
There was a problem hiding this comment.
It is better to either flip it in the call to_rgba or flip the return im below. Reassiging _A like this will cause the image to alternate orientation every time you called write_png.
|
Please do not backport this until after 2.0 final is out. |
| def write_png(self, fname): | ||
| """Write the image to png file with fname""" | ||
| if self.origin == 'upper': | ||
| self._A = self._A[::-1] |
There was a problem hiding this comment.
It is better to either flip it in the call to_rgba or flip the return im below. Reassiging _A like this will cause the image to alternate orientation every time you called write_png.
2c44b9f to
abcdf28
Compare
|
@Kojoley @tacaswell thanks. Is the test failure related to #7726? |
|
Yes, thanks, I thought that had been merged! |
|
|
||
| buff = io.BytesIO() | ||
| plt.imsave(buff, data) | ||
| plt.imsave(buff, data, origin='lower') |
There was a problem hiding this comment.
probably should save this with both origins and check that you get the correct output in both cases.
|
|
||
| buff = io.BytesIO() | ||
| plt.imsave(buff, data, origin='lower') | ||
| for origin in ['lower', 'upper']: |
There was a problem hiding this comment.
@tacaswell Added test here to test both lower and upper origin settings
Current coverage is 62.11% (diff: 100%)@@ master #7731 diff @@
==========================================
Files 174 174
Lines 56028 56028
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 34805 34803 -2
- Misses 21223 21225 +2
Partials 0 0
|
| def write_png(self, fname): | ||
| """Write the image to png file with fname""" | ||
| im = self.to_rgba(self._A, bytes=True, norm=True) | ||
| im = self.to_rgba(self._A[::-1] if self.origin == 'upper' else self._A, |
There was a problem hiding this comment.
Isn't this the wrong polarity?
There was a problem hiding this comment.
@tacaswell ugh, sorry. First I got mixed up on the origin polarity, then got my git rebasing all wrong. I think it should look ok now.
1ea49c5 to
92391b5
Compare
92391b5 to
d910788
Compare
|
Please do not backport this until after 2.0 final. |
|
Backported to |
Check origin when saving image to PNG


Fixes #7656.
Added an
origincheck and flips the image when appropriate when callingAxesImage.write_png()