Storing Jitter matrix in dict array?

Scott Findley's icon

Hello friends,

Really struggling to achieve something (I thought!) would be somewhat simple... What I have is a whole bunch of still images, album art, from mp3s, etc. which are collected into a single jitter matrix, and passed along into a numbered matrixset.

What I'd like to do, is be able to store the matricies, - not a reference to the matricies, in a dict array, I am assuming as a list if ints, though it makes no difference to me how they are stored... and preferably as a named data array within a dictionary, instead of an integer, as it is currently limited to within a 'matrixset' or at least as far as I can tell. The objective is that I may randomly recall and display them quickly and in a uniform format, and be able to recall them from saved datasets within dict.

jit.text seemed promising, but I just cant seem to get it to work. Im hoping one of you mega-smarties have done this or something like this before and can take my tender little hand and jetpack me to the mountaintop. THANKS!!!

Scott Findley's icon

Just to follow up - Im not really married to jitter or anything else - if there is a simple way for me to store an image file (or any binary file I suppose) within the structure of the dict system - ooh how that would please me. Anybody done anything along these lines?

Rob Ramirez's icon

if you want to save and recall matrices, the best format is the jitter matrix binary format. you can save and load this format using the "read" and "write" messages to jit.matrix and jit.matrixset

Ferenc Fabian's icon

hey Scott, have you found any solution for this?

Rob Ramirez's icon

You can do this with node.script and base64 images. You can read image files directly from disk and store them in a dictionary as base64 strings. You can then write those saved values back to disk as image files.

I've attached an example node-script and patch that shows how to send png image file paths to node, write them to a dictionary, output the dictionary back to Max, and then take a dictionary from Max and write the contents back to disk as png images. This only supports PNG files, for jpgs you'll have to modify the script.

You can easily expand on this to support matrices simply by first saving your matrix to disk as a temporary image file, using the exportimage command, and then sending that image path to the script for storage in the dict.

I might flesh this out a bit and chuck it on github. If I do I'll post a link here, but the attached files should get you going.

image-dict.zip
zip 4.99 KB