Convert equirectangular panorama image into pannellum supported multi-resolution image

(1) Get "generate.py" script from Pannellum github

(2) Download "Hugin" from cnet or sourceforge.

(3) Install "Hugin". We won't be using it, but we need a tool that comes with it - nona.

(4) Install Python3 with home brew.

brew install python

(5) Install a required Python library.

pip3 install Pillow

(6) Copy both "generate.py" and your target image into a directory.

(7) Run the following command:

python3 generate.py -n /Applications/Hugin/HuginStitchProject.app/Contents/MacOS/nona 001.jpg

(8) If this executed successfully, you will see an output directory generated. It should contains several numbered directory, a fallback directory and a config file. If your image is small (~5000px) you get about 3 levels. For higher resolution, you will get more numbered directories.


(9) Now by referring the config file, you can setup your Pannellum to use multi-res. E.g.

<script>
    viewer = pannellum.viewer('panorama', {
        "type": "multires",
        "hfov": 100.0,
        "multiRes": {
            "basePath": "/mres",
            "path": "/%l/%s%y_%x",
            "fallbackPath": "/fallback/%s",
            "extension": "jpg",
            "tileResolution": 512,
            "maxLevel": 3,
            "cubeResolution": 1832
        }
    });
</script>

(10) In the above example, the output dir is copied into a subdirectory named "mres" under the public(or www) directory. So you need to set "basePath". If you don't use a subdirectory, then please remove "basePath".

(11) Now you can load your 360 panorama image in Pannellum.



AI Summary
Chrome On-device AI 2024-12-06 19:38:35

Share Article