質問

I use MATLAB for calculating and plotting purposes. I want to write a plot as a image file like PNG or JPG into a MySQL database (that I can retreive later for a webbrowser). In other words I want to write a blob to the database that is a PNG or JPG file.

If I search for that I get http://www.mathworks.com/matlabcentral/answers/97768-how-do-i-insert-an-image-or-figure-into-a-database-using-the-database-toolbox-in-matlab but here a matrix of MATLAB is written as an array to a database. That is much bigger than a compressed PNG file and thus does not allow to see subplots and other things and cannot be displayed by a webbrowser.

A workaround would be to write the plot to a file and use MATLAB (or a external script tool based on python or so) to read that file as blob and write it as blob to the database.

Do you know a possibility to write a plot as PNG, JPG directly to a databse without the detour of a file?

役に立ちましたか?

解決

I also asked the MATLAB support and they gave me an positive answer. A solution is the figToImStream function of MATLAB compiler toolbox: "Stream out figure as byte array encoded in format specified, creating signed byte array in .png format". The downside is that MATLAB compiler toolbox is quite expensive...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top