Skip to content
Snippets Groups Projects
Commit 151e2b44 authored by Mayr, Hannes's avatar Mayr, Hannes
Browse files

Add ID to metadata of the png file. This is currently still buggy for the mpl engine.

parent 914b8f5b
No related branches found
No related tags found
1 merge request!49Draft: Add ID to metadata of the png file
Pipeline #853356 waiting for manual action
...@@ -55,15 +55,24 @@ def save_plot(figures, plot_names, extension="png"): ...@@ -55,15 +55,24 @@ def save_plot(figures, plot_names, extension="png"):
raise IndexError("There are more plot names than figures.") raise IndexError("There are more plot names than figures.")
plot_path = [] plot_path = []
exif_data_mpl = {
"Title": "Heyho",
"Author": "blub",
"Description": "Identiplier",
"Copyright": "R",
"Comment": "Test",
}
for i, fig in enumerate(figures): for i, fig in enumerate(figures):
if isinstance(fig, matplotlib.figure.Figure): if isinstance(fig, matplotlib.figure.Figure):
plt.figure(fig) plt.figure(fig)
plot_path.append(plot_names[i] + ".tmp." + extension) plot_path.append(plot_names[i] + ".tmp." + extension)
plt.savefig(plot_path[i]) plt.savefig(plot_path[i], metadata=exif_data_mpl)
elif all(x in str(type(fig)) for x in ["PIL", "ImageFile"]): elif all(x in str(type(fig)) for x in ["PIL", "ImageFile"]):
plot_path.append(plot_names[i] + ".tmp." + extension) plot_path.append(plot_names[i] + ".tmp." + extension)
fig.save(plot_path[i]) img_exif = fig.getexif()
img_exif[270] = "Identiplier2"
fig.save(plot_path[i], exif=img_exif)
else: else:
raise TypeError(f"Figure number {i} is not a valid figure object.") raise TypeError(f"Figure number {i} is not a valid figure object.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment