<p>Dump all your images into your timeline. Select one and <kbd>alt</kbd>-click the stopwatch on the position property, to add an expression. You need to write a javascript expression that returns an array of 3 numbers that will randomly position the image within the comp. This will do it:</p>

<pre class="lang-js prettyprint-override"><code>seedRandom(index, timeless = true);
var x = random(thisComp.width);
var y = random(thisComp.height);
var z = random(thisComp.width);
[x, y, z]
</code></pre>

<p>IF you right-click the position property and choose <strong>copy expression only</strong>, you can then paste it to all the other images in your comp and they will scatter to randomly fill a cube the size of your comp (and as deep on the z axis as the width of your comp).</p>

<h3>How it works</h3>

<p>(read this if you want to be able to hack it to your own needs)</p>

<p>The <code>seedrandom</code> function sets the random seed for the random number generator, and we give it two parameters, <code>index</code> meaning the layer number, and <code>timeless=true</code>. By using the layers' index to generate the random number, each layer will have a different set of coordinates. <code>Timeless=true</code> means that the random number doesn't change over time.</p>

<p><code>var x = Math.random(thisComp.width)</code> sets the variable x to have a random value somewhere between 0 and the width of the comp. If you wanted this to be a different value you could type in a number instead of <code>thisComp.width</code>. All three variables are set the same way.</p>

<p>The last line puts them into an array, which is what the position property needs.</p>

<p>To refine it you might want to use the guassRandom function instead of random - that will mean the images will cluster towards the centre, like a galaxy. You could also create a null and add three slider effects to it (in <strong>effects>expression controls</strong>). You could use them to control the width, height and depth of the cloud. To do that select the bit inside the random function that says <code>thisComp.width</code>, delete it and with the cursor inside the brackets grab the pick-whip (the little spiral near the expression twirl down) and drag it to the slider effect control. </p>

<p><a href="https://i.sstatic.net/pkThA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pkThA.png" alt="enter image description here"></a></p>

<p>The result should be that the line will now look like:</p>

<pre class="lang-js prettyprint-override"><code>var x = gaussRandom(thisComp.layer("Null 1").effect("Slider Control")("Slider"));
</code></pre>

<p>Do that for all three dimensions using a different slider for each and once again copy the expression to all the layers. Now you can control how far they spread with the sliders, and even animate it, by animating your sliders, so for example they could all spread out from the centre over time.</p>

CC BY-SA 3.0
2016-09-24T14:33:06.187Z
Thanks a LOT. This is perfect, I can do what I want with that (plus some tweak, but this is great already). I'll start learning Js asap.
DomSpiegel
CC BY-SA 3.0
2016-09-23T06:54:56.867Z
2016-09-23T06:54:56.867Z
stib
<p>I use <strong>After Effects</strong> CS6,</p>

<p>I need to add a lot of pictures inside my comp,</p>

<p>they need to have random position 
(if I could set the "range of the randomness" that would be great)</p>

<p>is there any way to do that ?</p>

<p>and I'm <strong>not</strong> looking at a wall image plugin (with these plugins, all pic are in the same plane, but I need randomness on the Z-axis too)</p>

<p>I'm trying to make something similar to the TV Show Person of Interest: how the AI has multiple image when "we" are inside "his mind". <a href="https://i.sstatic.net/dwKkS.jpg" rel="nofollow noreferrer">link to img</a></p>

<p>I have already done a big part of it manually, but it just takes too long to do it with new packs of images.</p>

<p>Thanks.</p>

<after-effects>
AE - is there a way to import images via list and add random position to them?
DomSpiegel
# AE - is there a way to import images via list and add random position to them?

(Asked by: username_0 on 2016-09-19)

I use **After Effects** CS6,

I need to add a lot of pictures inside my comp,

they need to have random position
(if I could set the "range of the randomness" that would be great)

is there any way to do that ?

and I'm **not** looking at a wall image plugin (with these plugins, all pic are in the same plane, but I need randomness on the Z-axis too)

I'm trying to make something similar to the TV Show Person of Interest: how the AI has multiple image when "we" are inside "his mind". [link to img](https://i.sstatic.net/dwKkS.jpg)

I have already done a big part of it manually, but it just takes too long to do it with new packs of images.

Thanks.

**Tags:** after-effects


---

## 1 answers

### Answer by username_1 on 2016-09-23. Score: 2 | Accepted answer

Dump all your images into your timeline. Select one and alt-click the stopwatch on the position property, to add an expression. You need to write a javascript expression that returns an array of 3 numbers that will randomly position the image within the comp. This will do it:
seedRandom(index, timeless = true);
var x = random(thisComp.width);
var y = random(thisComp.height);
var z = random(thisComp.width);
[x, y, z]

IF you right-click the position property and choose copy expression only, you can then paste it to all the other images in your comp and they will scatter to randomly fill a cube the size of your comp (and as deep on the z axis as the width of your comp).
How it works
(read this if you want to be able to hack it to your own needs)
The seedrandom function sets the random seed for the random number generator, and we give it two parameters, index meaning the layer number, and timeless=true. By using the layers' index to generate the random number, each layer will have a different set of coordinates. Timeless=true means that the random number doesn't change over time.
var x = Math.random(thisComp.width) sets the variable x to have a random value somewhere between 0 and the width of the comp. If you wanted this to be a different value you could type in a number instead of thisComp.width. All three variables are set the same way.
The last line puts them into an array, which is what the position property needs.
To refine it you might want to use the guassRandom function instead of random - that will mean the images will cluster towards the centre, like a galaxy. You could also create a null and add three slider effects to it (in effects>expression controls). You could use them to control the width, height and depth of the cloud. To do that select the bit inside the random function that says thisComp.width, delete it and with the cursor inside the brackets grab the pick-whip (the little spiral near the expression twirl down) and drag it to the slider effect control. 

The result should be that the line will now look like:
var x = gaussRandom(thisComp.layer("Null 1").effect("Slider Control")("Slider"));

Do that for all three dimensions using a different slider for each and once again copy the expression to all the layers. Now you can control how far they spread with the sliders, and even animate it, by animating your sliders, so for example they could all spread out from the centre over time.

> **Comments:**
> **username_0**: Thanks a LOT. This is perfect, I can do what I want with that (plus some tweak, but this is great already). I'll start learning Js asap.  

---

