# ImageIO from string/buffer

**URL:** https://discourse.itk.org/t/imageio-from-string-buffer/1261
**Category:** Engineering
**Created:** [September 7, 2018, 11:16pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261 "2018-09-07T23:16:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Simon](https://discourse.itk.org/user_avatar/discourse.itk.org/simon/32/789_2.png) [@Simon](https://discourse.itk.org/u/Simon)
#### Post date: [September 7, 2018, 11:16pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261/1 "2018-09-07T23:16:56Z")

</div>

I have an NRRD image that is embedded inside another file as a string. Of course I can extract it, write to a file, then use the usual ImageFileReader interface, but that’s wasteful as I already have the object in memory.

I seem to remember an effort a while ago to add IO from a stream to these classes, but cant’ find that now. Any pointers/ideas as to the easiest way to do this? I’m trying to avoid duplicating most of the functionality of NrrdImageIO … perhaps I’m just missing something easy (itk 4.10.x )

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 8, 2018, 2:41pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261/2 "2018-09-08T14:41:35Z")

</div>

I also vaguely remember such a discussion, but in my memory the conclusion was that ITK does not provide a mechanism to read an image from memory instead of from disk.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 8, 2018, 2:43pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261/3 "2018-09-08T14:43:35Z")

</div>

Is this the [discussion](https://discourse.itk.org/t/custom-imageiobase-class-for-loading-existing-buffer-through-image-file-reader/419), or was there another one?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 8, 2018, 2:48pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261/4 "2018-09-08T14:48:10Z")

</div>

Ah, here is an even earlier [discussion](https://itk.org/pipermail/community/2016-October/012232.html). The answer seems to be to use [itkFileFreeImageIO.h](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/ImageBase/test/itkFileFreeImageIO.h)

---

<div class="post-metadata">

### Author: ![Simon](https://discourse.itk.org/user_avatar/discourse.itk.org/simon/32/789_2.png) [@Simon](https://discourse.itk.org/u/Simon)
#### Post date: [September 10, 2018, 4:24pm UTC](https://discourse.itk.org/t/imageio-from-string-buffer/1261/5 "2018-09-10T16:24:25Z")

</div>

Thanks Dženan. I think that second link is the one I was looking for. I’ll dig around in both !
