I'm reading and output the picture as a plot:
import numpy as np
import os
import matplotlib.pyplot as plt
import matplotlib.ticker as tkr
fig, ax = plt.subplots()
path = 'photo.jpg'
im = plt.imread(path)
ax.imshow(im)
After I want to save it and check(see) the image before saving, but my code generate empty image:(
plt.axis("off")
plt.gca().xaxis.set_major_locator(tkr.NullLocator())
plt.gca().yaxis.set_major_locator(tkr.NullLocator())
filename = os.path.basename(path).split(".")[0]
output_path = os.path.join("test", filename+".png").replace("/", "")
plt.savefig(output_path, bbox_inches="tight", pad_inches=0.0)
plt.show()
plt.close()
source https://stackoverflow.com/questions/70106331/jupiter-saves-an-empty-photo-although-it-shows-it-before-how-to-fix-that
Comments
Post a Comment