# Loading an image in place

**URL:** https://discourse.julialang.org/t/loading-an-image-in-place/135276
**Category:** Performance
**Created:** [January 26, 2026, 8:51pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276 "2026-01-26T20:51:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mj2984](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mj2984/32/43833_2.png) [@mj2984](https://discourse.julialang.org/u/mj2984)
#### Post date: [January 26, 2026, 8:51pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276/1 "2026-01-26T20:51:21Z")

</div>

Is there any method available in general libraries that can load images to a pre allocated array (to avoid allocations during runtime), assuming the user knows the image size (or pre allocates a larger array and fills a view of it). For videos there is a function VideoIO.read! that does this, but I’m unaware of any for images.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [January 26, 2026, 10:10pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276/2 "2026-01-26T22:10:59Z")

</div>

What kind of image format?

---

<div class="post-metadata">

### Author: ![mj2984](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mj2984/32/43833_2.png) [@mj2984](https://discourse.julialang.org/u/mj2984)
#### Post date: [January 26, 2026, 10:17pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276/3 "2026-01-26T22:17:33Z")

</div>

Hopefully, as many formats as possible. For starters, uncompressed formats like portable graytone map.

---

<div class="post-metadata">

### Author: ![noetheriankoala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noetheriankoala/32/218462_2.png) [@noetheriankoala](https://discourse.julialang.org/u/noetheriankoala)
#### Post date: [January 26, 2026, 10:22pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276/5 "2026-01-26T22:22:31Z")

</div>

Have you looked into [memory-mapped IO](https://docs.julialang.org/en/v1/stdlib/Mmap/)? Whether this is what you want will depend on the format of your image; I suggest providing more detail in your question (see [here](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)).

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [January 26, 2026, 10:50pm UTC](https://discourse.julialang.org/t/loading-an-image-in-place/135276/6 "2026-01-26T22:50:03Z")

</div>

GDAL reads pretty much everything and it requires that a pre-allocated buffer is passed in to store the image. So, I guess ArchGDAL.jl and GMT.jl ([gdalread](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/gdalfuns/gdalread.html) function, but this is only from memory) should fill your condition.
