Jump to content

Import a whole folder of images in one time? (no sequence)


Krion

Recommended Posts

Hi,

 

I would like to import a whole folder of images and use them for randomness effects / iterate over them / etc.

But it is no images and they are all named differently.

 

Is this possible?

 

Thanks in advance. :) 

Link to comment
Share on other sites

You want to import them where ? In COPs by creating nodes that read random omages in a folder (so as many nodes than images ??) ? Or do you want to generate a path attribute on geometry or parameter on a node that takes random values among all the path and image names of a folder ?

In both cases, Python is the answer.

Otherwise, is they are named sequentially already in your folder, you can easily rebuild a string that match that in VEX.

We probably need more info on what you want to achieve precisely to guide you.

Edited by StepbyStepVFX
Link to comment
Share on other sites

I want something like this:

To import a whole folder of images and be able to have a parameter that goes through them (like you can with the "Select Input" parameter on a switch).

And then I wanted to use a Trace SOP on it, but now I see that the Trace SOP has no input, but only a file-path parameter itself.. 

 

Hope it is possible in VEX because that I know a bit.

Can you also 'rebuild a string' in VEX when they have the same prefix, but not numbered sequentially? 

Like: 

Person.Bob.jpg

Person.Jane.jpg

 

Thanks again. :) 

Edited by Krion
Link to comment
Share on other sites

Hi Dave,

you could feed the trace SOP with image file paths from a python node:

import os
import glob

node = hou.pwd()
node_tracer = hou.node('../trace1')
dir = node.evalParm('dir')
num = node.evalParm('num_img')

path = hou.expandString(dir)
os.chdir(dir)
files = glob.glob('*.jpg')

total_num = len(files) - 1
num = max(min(total_num, num), 0)

image = files[num]
node_tracer.parm('file').set(image)

 

read_image_folder.hipnc

  • Thanks 1
Link to comment
Share on other sites

22 minutes ago, Krion said:

How good do you think you need to be in VEX before you tackle Python? 

As long as your Python usage is only about listing files, setting parameters, creating nodes and such I don't think you have to wait. The language has very little to do with VEX anyway.

I mainly put together my python scripts by combining results from stackoverflow, odforce threads and SideFX's documentation.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 3/10/2019 at 1:15 AM, konstantin magnus said:

As long as your Python usage is only about listing files, setting parameters, creating nodes and such I don't think you have to wait. The language has very little to do with VEX anyway.

I mainly put together my python scripts by combining results from stackoverflow, odforce threads and SideFX's documentation.

any idea how to import cache sequence from multiple folder using python.

 

Basically i wedge a simulation and i want to import all cache once and add a switch node to select the best output

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...