# Example of loading images using itk-wasm?

**URL:** https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275
**Category:** Beginner Questions
**Tags:** itk-wasm
**Created:** [October 21, 2024, 4:53pm UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275 "2024-10-21T16:53:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dstansby](https://discourse.itk.org/user_avatar/discourse.itk.org/dstansby/32/3927_2.png) [@dstansby](https://discourse.itk.org/u/dstansby)
#### Post date: [October 21, 2024, 4:53pm UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275/1 "2024-10-21T16:53:11Z")

</div>

I’m looking to render a 3D TIFF file using `vtk.js`, and I understand I can handle the reading of the images using `itk-wasm`, and then convert it to a VTK object. I’m struggling to understand from the `itk-wasm` API docs how I can do this though… can anyone point to a self contained example showing how I can read in a 3D TIFF file using `itk-wasm`?

---

<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: [October 21, 2024, 6:22pm UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275/2 "2024-10-21T18:22:57Z")

</div>

Reading a 3D TIFF should not be different from reading a 3D NRRD or 3D MetaImage. Did you take a look at [docs](https://wasm.itk.org/en/latest/introduction/packages.html), section `@itk-wasm/image-io`? It has demo and doc links.

@jadh4v and @Forrest might provide more info.

---

<div class="post-metadata">

### Author: ![dstansby](https://discourse.itk.org/user_avatar/discourse.itk.org/dstansby/32/3927_2.png) [@dstansby](https://discourse.itk.org/u/dstansby)
#### Post date: [October 22, 2024, 8:19am UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275/3 "2024-10-22T08:19:51Z")

</div>

Thanks, I did look at the [@itk-wasm/image-io docs](https://insightsoftwareconsortium.github.io/ITK-Wasm/image-io/ts/docs/) but it just seems to have API reference and no examples.

---

<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: [October 22, 2024, 2:32pm UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275/4 "2024-10-22T14:32:49Z")

</div>

Have you seen [itk-vtk-viewer](https://github.com/Kitware/itk-vtk-viewer)? It is self-contained, though a bit big. Or [these examples](https://wasm.itk.org/en/latest/typescript/distribution/index.html) from the docs?

---

<div class="post-metadata">

### Author: ![PaulHax](https://discourse.itk.org/user_avatar/discourse.itk.org/paulhax/32/2949_2.png) [@PaulHax](https://discourse.itk.org/u/PaulHax)
#### Post date: [October 22, 2024, 6:05pm UTC](https://discourse.itk.org/t/example-of-loading-images-using-itk-wasm/7275/5 "2024-10-22T18:05:42Z")

</div>

The vite example dzenanz linked to is good. The link to the actual code is broken sadly, but now here:

> **[ITK-Wasm/examples/vite at main · InsightSoftwareConsortium/ITK-Wasm](https://github.com/InsightSoftwareConsortium/ITK-Wasm/tree/main/examples/vite)**
>
> High performance spatial analysis in a web browser and across programming languages and hardware architectures - InsightSoftwareConsortium/ITK-Wasm

Another example, the itk-viewer repo uses itkwasm in a smaller code base.

First need to configure how to where to load .wasm files at runtime:

> <https://github.com/InsightSoftwareConsortium/itk-viewer/blob/main/packages/element/examples/assetPathSetup.ts#L1-L6>

That runtime location is defined by vite in this repos case:

> <https://github.com/InsightSoftwareConsortium/itk-viewer/blob/main/packages/element/vite.config.ts#L34-L43>

The actual call to `readImage`

> <https://github.com/InsightSoftwareConsortium/itk-viewer/blob/main/packages/element/examples/image-io-read-image.ts#L29>

If you have the time, feel free to open an issue or PR updating docs at the itk-wasm repo. =)
