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
imsave-generated PNG files missing edges for certain resolutions #6855
Comments
Duplicate of #6813? |
Don't think so. [Edit] To clarify: #6813 is about imshow, with an artist with axes and ticks and display bounds and so on, while this one is about imsave, which appears to save an RGBA array directly as a PNG file. |
In the worst maintainer answer ever, I can not reproduce this on linux from the v2.x branch, but can reproduce this with v1.5.1 import numpy as np
import matplotlib.pyplot as plt
import tqdm
from io import BytesIO
for j in tqdm.tqdm(range(2, 5000)):
buff = BytesIO()
n = np.zeros((j, j))
plt.imsave(buff, n)
buff.seek(0)
shp = plt.imread(buff).shape
assert (j, j, 4) == shp, (j, shp) The set of sizes which fail in 1.5.1 is much wider than what the OP list, at least up to In [15]: print(sorted(fail)) (and at that point I got tired of waiting for the code to run). The 2.x code is at over 3k at this point and has not failed yet. @Salganos Thank you for reporting this, but I am going to close as already fixed. I suspect that @mdboom (accidentally?) fixed this with some recent work on the png interface. |
All right. That's relieving, actually. Thanks. |
This is a bit of an odd problem, but has been reproducible for me in both Matplotlib 1.5.2 on Python 3.5.2 from Macports on Mac OS X 10.9.6 and Matplotlib 1.5.1 on Python 3.5.1 from Anaconda on Windows 10, both running on 64-bit 4-core Intel i7 processors (of significantly differing ages).
Any array with a dimension of 3421*2^n, for a non-negative integer n, will be missing one line along that dimension when saved as a PNG file through
imsave
. For example:Inspection of the file through the OS will also show the shortened resolution, and saving a more detailed image will show the missing lines are taken from the top and the right. Saving an RGB or RGBA array has the same result.
Considering the nature of the pattern, this would seem to be some sort of floating-point rounding error, though I have not been able to find a location it might occur. I also cannot currently confirm if it happens for more recent versions, such as is currently in this repository.
The text was updated successfully, but these errors were encountered: