# How to use ImageMultiply[] over a list of strings?

I'm trying to do the following:

l = FileNames[];
s[x_] := ToString[l[[x]]]
t = Table[s[x], {x, 1, Length[l]}];
i[x_] := Import[t[[x]]]
m[x_] := ImageMultiply[i[x], i[x + 1]]


This is supposed to take two images of one folder and multiply them. But I want to take two images and multiply them, then I want to take the next two, multiply them and multiply to the last multiplied images and proceed like this for all the images in the folder.

I already have a table with all the file locations, the problem is that ImageMultiply[] doesn't take lists as inputs. I wasn't able to do something like:

ImageMultiply[t]


Which would solve the problem, but the input of this function is:

ImageMultiply[image1,image2,...]


And not:

ImageMultiply[{image1,image2, ...}]


Perhaps there is some way of drop all the elements out of the list into that function, I don't know about it. I've also looked some functions that look extremelly similar to what I'm trying to do, I guess that there's some way to use NestList[] or Nest[] to do it, but I've tried a few experiments and it resulted in hazard...$^1$

$1$ - I don't remember precisely which arguments (then I chose arbitrary ones) I used in that function, but it really froze my computer.

• Take a look at Fold[] – Dr. belisarius Feb 25 '14 at 14:22
• @belisarius I've done the following. But I have no idea on why it's not working. – Billy Rubina Feb 25 '14 at 14:36

   SetDirectory["whatever"];

• @PristineKavalostka Err ..not much to say.It's a basic recursive form Fold[f,x,{a,b}] -> f[f[x,a],b] – Dr. belisarius Feb 25 '14 at 14:59