I am generating some Histograms from the gonum/plot library in Go. Normally you would save the image, as .png for instance like this:
if err := plot.Save(2.5*vg.Inch, 2.5*vg.Inch, "my_histo.png"); err != nil {
log.Println("[!] error creating plot", err)
}
And this generates all the .png at the folder. No issue with that.
I want to use this plots on a GUI(Python tk) and basically I want to store them in an SQLITE database, with a text key that corresponds to the physical object, which this histogram data was generated from, in order to access them from Python. On the GUI, there is a dictionary and you choose which histogram data you wish to display, and this is synced from the database.
I want to save this png Histogram at a column in my Database that it is Blob type and then I want to extract it from there, when needed.
Now, I know that this might not be the best way to implement this, but I would like to understand how Reader/Writer works, so I would like to know if I can do what I describe and if yes, how?
For example, I can generate those png histograms on a folder and then save the location that they were saved as a text at the database, instead of sending larger amount of bytes, but I was wondering if I can avoid saving the png and save it directly at the database, as a []bytes possible?
To that extend, I noticed that my plot object has the attribute WriterTo and I can do something like this:
n, err := plot.WriterTo(2.5*vg.Inch, 2.5*vg.Inch, "png")
This returns the number of bytes written, and if there was an error. So, what is this actually useful for? How do I access my data/png, after using this WriterTo method?