How to import random images (png,jpeg...) from a folder to jit.matrix automatically

Rufles Man's icon

Hello guys,

I'm new to Max and i'm doing a project that needs to import different random images from a folder to jit.matrix.
I know that i can use "importmovie" but i can't make it work like the way I want it.
There's any way that I can import randomly and specifically from a folder, in an automatic way?

Thank you in advance

Rob Ramirez's icon

load a folder of images into a umenu using the prefix attribute (make sure "autopopulate" is enabled), route for "populate" out the dump out, send that to an random/urn/urn-jb object as the range, bang that object and send the output to the umenu, send the output of the umenu as the arg to the importmovie message:

Max Patch
Copy patch and select New From Clipboard in Max.

Rufles Man's icon

Oh my god, thank you.
Really, thank you. You don't imagine the hours that i spent trying to make this work and it was so simple.
Man you have a place in heaven.

All the best

Shane's icon

I know this is a really old thread, but I found this while looking for a solution to combine 2 randomly selected images.

Rob's patch really helped me think about what I need to do (thanks!). Basically, I copied everything so that there are two images selected, then I routed the outputs to a jit.glue object. Works great if both images have the same proportions, but half of the image is black if this isn't the case. I am working with one folder of images that are all the same proportion, but another where they are not. Ideally, I would like to have the mixed proportion images open up in the background and the others on top (on the left or right side of the window). I'm attaching the patch here.

Any thoughts on how to make this work?

slideshow2.maxpat
Max Patch

TFL's icon

If you want to display an image in the background and another on top of it, then jit.glue will be useless. Also, depending on what you want to do in the end, you might prefer to use GL textures instead of matrices, for better performances.

Here I adapted your patch to use textures instead of matrices, with the left player appearing in the background. [jit.gl.layer] makes the image to appear, and its @layer attribute define the rendering order (lower number means rendered first, which means that it will be hidden by things that will be rendered next). Depending on your image dimension and the desired output, you might need to play with its @scale attribute as well to make the image fill the entire screen regardless of its aspect ratio (requires a bit of math).

Max Patch
Copy patch and select New From Clipboard in Max.

Shane's icon

Thanks very much, @TFL! This is really helpful!