# How to save renderer output (vtk python) in format that is compatible on web side(vtk.js)

**URL:** https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482
**Category:** Support
**Created:** [December 23, 2021, 8:34am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482 "2021-12-23T08:34:33Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![khadija](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@khadija](https://discourse.vtk.org/u/khadija)
#### Post date: [December 23, 2021, 8:34am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/1 "2021-12-23T08:34:33Z")

</div>

i want all the processing on python vtk side and send the resulting file on vtk.js side on webGL that only rendered the results.

i want to save renderer output in any file format , that can be used on the other end side (vtk.js) just to render the results. kindly provide sugessions

code

renderer = vtk.vtkRenderer()  
volume, mask = setup\_volume(renderer, LiverVolume\_FILE), setup\_mask(renderer, LiverMask\_FILE)  
#volume\_image\_prop = setup\_projection(volume, renderer)  
#volume\_slicer\_props = setup\_slicer(renderer, volume)

renWin = vtk.vtkRenderWindow()  
renWin.AddRenderer(renderer)  
renWin.SetSize(900, 900)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [December 23, 2021, 11:35pm UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/2 "2021-12-23T23:35:47Z")

</div>

You should use [vtkJSONSceneExporter](https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Export/vtkJSONSceneExporter.h) from Python and [HttpSceneLoader](https://kitware.github.io/vtk-js/examples/HttpSceneLoader.html) in vtk.js.

You can see its integration into [ParaView](https://www.kitware.com/exporting-paraview-scenes-to-paraview-glance/) and [Glance](https://kitware.github.io/paraview-glance/index.html).

---

<div class="post-metadata">

### Author: ![khadija](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@khadija](https://discourse.vtk.org/u/khadija)
#### Post date: [December 24, 2021, 6:00am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/3 "2021-12-24T06:00:11Z")

</div>

> [@Sebastien\_Jourdain](#):
>
> [HttpSceneLoader](https://kitware.github.io/vtk-js/examples/HttpSceneLoader.html)

Thankyou soo much it worked 🙂

---

<div class="post-metadata">

### Author: ![khadija](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@khadija](https://discourse.vtk.org/u/khadija)
#### Post date: [December 28, 2021, 6:13am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/4 "2021-12-28T06:13:42Z")

</div>

> [@Sebastien\_Jourdain](#):
>
> [vtkJSONSceneExporter](https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Export/vtkJSONSceneExporter.h) from Python and [HttpSceneLoader](https://kitware.github.io/vtk-js/examples/HttpSceneLoader.html) in vtk.js.

code used in python vtk to export  
exporter=vtk.vtkJSONSceneExporter()  
exporter.SetFileName(“3Dscene”)  
exporter.SetInput(renWin)  
exporter.SetActiveRenderer(renderer);  
exporter.Write()

as a result of vtkjsonsceneexporter i got index.json and 3 folder files (folders contain index.json file and a data folder contains some float and int file ) , i am not able to understand these , when i load these filles in paraview it gives error. can you please explain  
 ![files](https://discourse.vtk.org/uploads/default/original/2X/d/d1288f2a1eb5a0ccb01e91b4ea9023466f3a9a3b.png)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [December 31, 2021, 9:22pm UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/5 "2021-12-31T21:22:35Z")

</div>

ParaView (Qt application) does not know how to read those files. But if you zip it and rename it to `something-you-like.vtkjs`, Glance should be able to read it.

---

<div class="post-metadata">

### Author: ![khadija](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@khadija](https://discourse.vtk.org/u/khadija)
#### Post date: [January 1, 2022, 12:54pm UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/6 "2022-01-01T12:54:47Z")

</div>

Thankyou it worked on glance , want to know one thing as i am new to vtk.js as when i used HttpSceneLoader on js side using webpack i am following the basic cone example ([Starting a vtk.js project from scratch | vtk.js](https://kitware.github.io/vtk-js/docs/vtk_vanilla.html)) and adding my own things in it, but it gives the error , you know how to sort this out.

This is my index.js in src folder.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/fd9144609a8a9e127be500827b2168457b8b0c50.png)

this is my index.html in dist folder

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/fd9144609a8a9e127be500827b2168457b8b0c50.png)

ERROR by running npm run command

 ![error](https://discourse.vtk.org/uploads/default/original/2X/7/7bf3ce6cb101ba92a796959bde2bc2e1704439be.png)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [January 1, 2022, 4:50pm UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/7 "2022-01-01T16:50:23Z")

</div>

If you read the documentation you pointed out, you will notice that the imports are not the same.

`vtk.js/Sources/*`  
vs  
`@kitware/vtk.js/*`

---

<div class="post-metadata">

### Author: ![khadija](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@khadija](https://discourse.vtk.org/u/khadija)
#### Post date: [January 7, 2022, 5:59am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/8 "2022-01-07T05:59:54Z")

</div>

thankyou 🙂

---

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [June 27, 2025, 11:52am UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/9 "2025-06-27T11:52:48Z")

</div>

Hello, I am trying to use this, but I do not understand what renWin is supposed to be, and the [vtkJSONSceneExporter documentation](https://vtk.org/doc/nightly/html/classvtkJSONSceneExporter.html) does not seem to help, since these methods are not listed.

---

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [June 27, 2025, 12:03pm UTC](https://discourse.vtk.org/t/how-to-save-renderer-output-vtk-python-in-format-that-is-compatible-on-web-side-vtk-js/7482/10 "2025-06-27T12:03:49Z")

</div>

Maybe I figured it out:

```auto
exporter = vtkJSONSceneExporter()
exporter.SetFileName(out_file_name)
exporter.SetInput(self.plotter.renderer.GetRenderWindow())
exporter.SetActiveRenderer(self.plotter.renderer)
exporter.Write()

```

where self.plotter is a [PyVista plotter](https://docs.pyvista.org/api/plotting/_autosummary/pyvista.plotter)
