Skip to content

fix(assimp): pass -f<format> so non-extension targets work#557

Merged
C4illin merged 3 commits intoC4illin:mainfrom
dantebarbieri:fix/assimp-explicit-output-format
Apr 22, 2026
Merged

fix(assimp): pass -f<format> so non-extension targets work#557
C4illin merged 3 commits intoC4illin:mainfrom
dantebarbieri:fix/assimp-explicit-output-format

Conversation

@dantebarbieri
Copy link
Copy Markdown
Contributor

@dantebarbieri dantebarbieri commented Apr 22, 2026

My ConvertX on my HomeServer failed to convert an STL file I found into a GLB file using the GLB2 format in assimp.

tools/assimp_cmd/Export.cpp:54 seems to indicate we need to pass -f<h> where <h> is the format. And it can't infer since the extension for format glb2 is .glb: code/Common/Exporter.cpp:188. That's in line with the spec: https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/Specification.adoc

But if you just use glb2 with -fglb2, then the output from ConvertX is a .glb2 file which must be renamed, so I altered the normalizeOutputFiletype function to handle these filetypes in assimp.

Screenshot 2026-04-22 at 1 19 34 PM

Shows this working in my self-hosted ConvertX instance.


Summary by cubic

Pass -f<format> to assimp export so non-extension format IDs (e.g., glb2, stlb) export reliably, and write real file extensions so outputs open in viewers.

  • Bug Fixes

    • Always call assimp export with -f${convertTo} to bypass extension inference and fix failures for non-extension targets (glb2, gltf2, objnomtl, stlb, plyb, fbxa, assjson).
    • Normalize output filenames: glb2.glb, gltf2.gltf, objnomtl.obj, stlb.stl, plyb.ply, fbxa.fbx, assjson.json.
  • Refactors

    • Prettier formatting in assimp.ts (no behavior changes).

Written for commit f7bbe71. Summary will update on new commits.

The assimp converter invokes `assimp export <in> <out>` and relies on
assimp's extension-based format inference to pick the output format.
That works for targets whose id happens to match a real file extension
(glb, gltf, obj, stl, ply, etc.) but silently fails for every target
whose assimp id is not a conventional filename extension:

  glb2, gltf2, objnomtl, stlb, plyb, fbxa, assbin, assxml, pbrt, assjson

Picking any of those in the UI aborts the job with:

  assimp export: no output format specified and I failed to guess it

assimp_cmd's `-f<h>` flag overrides extension inference, and the values
in `properties.to.object` already correspond 1:1 to assimp's format ids
(verified against `assimp listexport`). Passing `-f${convertTo}` makes
every advertised target work without changing anything else.

Reproduction: upload any .stl, convert to glb2. Before: ENOENT on the
nonexistent output file. After: valid binary glTF 2.0.
Follow-up to the previous commit. With `-f<format>` now passed to
assimp, every advertised target exports successfully — but seven of
them still produce files with assimp's internal format id as the
extension, which no third-party viewer recognises:

  glb2 → .glb2   (really binary glTF 2.0, should be .glb)
  gltf2 → .gltf2 (text glTF 2.0, should be .gltf)
  objnomtl → .objnomtl   (OBJ without .mtl, should be .obj)
  stlb → .stlb   (binary STL, should be .stl)
  plyb → .plyb   (binary PLY, should be .ply)
  fbxa → .fbxa   (ASCII FBX, should be .fbx)
  assjson → .assjson   (JSON dump, should be .json)

Map these in `normalizeOutputFiletype`, the same helper that already
handles jpeg→jpg, latex→tex, markdown→md. The format id on `convertTo`
is untouched, so `assimp -f<id>` still selects the correct
encoding/variant — only the output filename changes.

assbin, assxml, and pbrt are both the format id and the canonical
extension, so they need no mapping.
@github-actions github-actions Bot added Fix and removed Fix labels Apr 22, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

dantebarbieri added a commit to dantebarbieri/homeserver that referenced this pull request Apr 22, 2026
Smoke test on the fork's fix/assimp-explicit-output-format branch
passed (STL → glb2 produces a valid `.glb` binary glTF 2.0 file).
Upstream PR filed at C4illin/ConvertX#557 — once merged, the next
`:latest` pull picks up the fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@C4illin C4illin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Well done

@dantebarbieri dantebarbieri requested a review from C4illin April 22, 2026 20:27
@github-actions github-actions Bot added Fix and removed Fix labels Apr 22, 2026
@C4illin C4illin merged commit 1ba82cf into C4illin:main Apr 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants