# Loading lots of images

**URL:** <https://discourse.julialang.org/t/loading-lots-of-images/17125>\
**Category:** Performance\
**Created:** [November 3, 2018, 8:55pm UTC](https://discourse.julialang.org/t/loading-lots-of-images/17125 "2018-11-03T20:55:08Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [November 5, 2018, 7:59pm UTC](https://discourse.julialang.org/t/loading-lots-of-images/17125/6 "2018-11-05T19:59:57Z")

</div>

I’m having one more problem: I would like to run the computation for the folders in “parallel” and reading the [documentation about channels](https://docs.julialang.org/en/v1/manual/parallel-computing/) I see that channels are well suited for such an I/O intensive task.

However, since I have a lot folders, I would like to control the number of “concurrent” tasks. The documentation I link to above have an example where sleeping processes run 4 at a time, but I cannot figure out how to adapt that to my situation.

With an `average_image` function like in my first post I have a wrapper that saves the output:

```
save_average(dir, sz)
    files = joinpath.(dir, readdir(dir))
    avgimg = average_image(files, sz)

    savename = string(dir, ".png")
    save(savename, avgimg)
end

```

Processing all folders at once as explained in [this question](https://discourse.julialang.org/t/example-of-async-distributed-loading-into-a-single-shared-channel/11815), which I fear is too agressive:

```
@sync for dir in dirs
    @async save_average(dir, sz)
end

```

---

_[View the full topic](https://discourse.julialang.org/t/loading-lots-of-images/17125)._
