Based on Matt’s video I wondered if it would be possible to leverage Gemini to build an app to recover my lost work?
My reasoning was simple: Pano2VR cuts the original equirectangular images into those hundreds of smaller tiles.
These tiles, though fragmented, still contain all the visual information of the original.
Each tile is a piece of a larger puzzle, and with enough data and the right algorithms, and Gemini might be able to piece them back together.
Gemini to the Rescue: Crafting the Recovery Script
So, I turned to Gemini with the idea that it could help me develop an application to speed up this arduous recovery process. I explained the situation, detailing the specific folder structure created by Pano2VR and the need for dynamic dimension handling.
My prompt to Gemini, although I didn’t know it at the start, essentially asked for a Python script to:
-
Navigate a deeply nested folder structure: Specifically targeting l_4 folders within cf_Y folders inside a nodeXXX root.
-
Dynamically infer image dimensions: Instead of hardcoding sizes, the script needed to analyze existing tiles to determine the correct dimensions for combining them, with fallback defaults if inference was ambiguous.
-
Combine tiles into cube faces: Vertically combining tiles into columns, then horizontally combining columns into complete cube faces (one for each of the six faces).
-
Handle errors and adapt: Print warnings for missing files or unexpected sizes, and critically, resize images if necessary to fit the dynamically inferred target dimensions, ensuring a complete output even if it meant minor distortions.
-
Accept command-line arguments: To specify which nodeXXX folder to process.
-
Output to a unique folder: Organizing the reconstructed cube faces clearly.
After this initial prompt, Gemini got to work, letting me know that it would use Python and leverage the Pillow library.
Note: The Pillow library in Python is a powerful and user-friendly fork of the classic PIL (Python Imaging Library). It’s an essential tool for anyone working with images in Python, offering extensive capabilities for image manipulation, processing, and saving.
The journey to the perfect solution wasn’t immediate, but a fascinating iterative process. My primary concern was ensuring the script could dynamically infer image dimensions for each panorama node, rather than relying on any hardcoded sizes. I wanted it to adapt flawlessly, whether a tile was 512 x 512px or something slightly different, ensuring no distortions were introduced during the reconstruction.
We went back and forth, refining the logic. My focus was on:
-
Analyzing Size Dependencies: How could the script read image size to accurately calculate the original tile, column, and row dimensions?
-
Implementing Size Inference: Developing robust methods to derive actual dimensions directly from source images within each node directory. This meant moving away from “expected size” warnings and instead making the script adapt to the actual sizes it found.
-
Orchestrating Size Adaptations: Restructuring the image combination logic entirely so that images were always combined at their native sizes. If a tile’s dimensions didn’t perfectly align with its inferred position, the script would still proceed, resizing only when absolutely necessary to fit the dynamically determined target, but always prioritizing the original dimensions where possible. This ensured the integrity and seamlessness of the final cube faces.
Through this collaborative refinement, Gemini built a script, combined_panoramas.py, that could do the following:
-
Intelligently examine the scattered tiles
-
Dynamically determine their individual sizes
-
Extrapolate the final cube face dimensions
-
Seamlessly stitch the individual tiles together to create a single cube face
-
Repeat for each of the other five individual cube faces
-
Create a new folder,
-
Name the folder to match the original tile folder name
-
Save the cube faces into the new folder
-
All of this, in lightning speed
Once I had the 6 cube faces for each panorama then I could leverage Pano2VR’s ability to detect cube faces and render them as Equirectangular files.
The Script at and Pano2VR at Work
The video below shows the complete solution from examining the tile file structure, to running the script, loading the cube faces, transforming the cube cross to and equirectangular image and updating and outputting the original tour.














