Exported scenes carry each texture as raw RGB, which a compressed image could shrink tenfold

Open
#128 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, python
Domain
full-stack

Research direction

Start by tracing how the serializer writes a vtkTexture's vtkImageData and how vtk.js's scene loader handles textures; the issue names no files or tests. Check vtkTexture's setImage and setImageBitmap APIs and whether the approach needs changes in vtk.js as well. Done means scenes can use compressed texture bytes and the client decodes them, with the export size measured on geovista scenes.

Written by the indexing model from the issue text.

Description

This issue was researched and drafted by an AI agent (Claude Code) working with the geovista maintainer, who reviewed it before it was posted.

Exported scenes carry each texture as raw RGB

trame_vtk's serializer writes a vtkTexture's input as a vtkImageData whose point data is the decoded pixels, a Uint8Array of width × height × components. A texture loaded from a JPEG therefore enters a .vtksz scene, or a client-side view, at its full decoded size.

geovista embeds pyvista scenes in its documentation, exported with plotter.trame.export_vtksz. Its base layer's texture is a 7,020 × 3,510 RGB JPEG:

The same texture Size
raw RGB in a scene, as exported today, zipped 38.9 MB
as a PNG 26.3 MB
re-encoded as a JPEG at quality 85 4.5 MB
the source JPEG 3.4 MB

The texture is in 31 of the documentation's 47 scenes and makes up 983 MB of their 1,693 MB. That puts the build over the 1,024 MB per format that Read the Docs now allows (readthedocs/readthedocs.org#13287), and a reader downloads it each time a page opens a scene. Our workaround resamples each texture to 2,048 pixels wide after export (bjlittle/geovista#2961), so a reader who zooms in sees a softer image.

What would help

The serializer could write a texture's image as compressed bytes, as a PNG to stay lossless or as a JPEG when the source was one, and the client would decode them. vtk.js's vtkTexture already takes an HTMLImageElement or an ImageBitmap through setImage and setImageBitmap, so the scene loader could decode the bytes with createImageBitmap and pass the result to the texture. That means changing both the serializer here and the texture handler of vtk.js's scene loader, so part of this may belong in vtk.js.

If the approach fits, we'd be glad to open a pull request for the serializer side and measure the result on geovista's scenes.

Dominant language
HTML
Stars
37
Forks
21
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Kitware/trame-vtk

All issues in Kitware/trame-vtk

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.