1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

importing random images

Posted by CB on Sep 07, 2009

hi there,
i'm new to this software, and i can't figure out how to import a random image from a selected folder i created on my computer. it's probably the easiest thing, but still... thanks for your help!


 
Posted by Stefan on Sep 07, 2009

This snippet will do that:

extensions = [".png", ".jpg", ".gif"]
fi=[f for f in files("/path/to/your/dir") if any(f.endswith(ext) for ext in extensions)]
if fi:
    image(choice(fi),0,0)



Posted by lievn on Sep 15, 2009

img = choice(files("yourFolder/*.jpg"))
is maybe a bit more comprehensive..