Python package for GLTF Draco transcoding with C++ backend
Project description
gltf_draco_transcoder
A high-performance Python package for compressing and decompressing glTF/glb files using the Draco 3D data compression library. This package provides both a Python API and a command-line interface for efficient 3D model compression.
Features
- Compression: Compress glb files using Draco compression to reduce file sizes significantly
- Decompression: Decompress Draco-compressed glb files back to standard glTF format
- High Performance: C++ backend with Python bindings for maximum performance
- Cross-platform: Supports Windows, macOS (ARM64), and Linux (including ARM64)
- Configurable: Fine-tune compression quality with quantization and compression level settings
- Easy Integration: Simple Python API and command-line interface
Installation
Install from PyPI:
pip install gltf_draco_transcoder
Usage
Python API
Basic Compression
from gltf_draco_transcoder import compress_gltf, decompress_gltf
# Compress a glTF/glb file
compressed_data = compress_gltf('input.glb')
# Save compressed data
with open('output_compressed.glb', 'wb') as f:
f.write(compressed_data.getvalue())
# Decompress back to glTF/glb
decompressed_data = decompress_gltf('output_compressed.glb')
with open('output_decompressed.glb', 'wb') as f:
f.write(decompressed_data.getvalue())
Advanced Compression with Custom Options
from gltf_draco_transcoder import compress_gltf, DracoOptions
# Create custom compression options
options = DracoOptions()
options.quantization_position = 14 # Higher quality for positions
options.quantization_normal = 10 # Higher quality for normals
options.compression_level = 9 # Higher compression effort
# Compress with custom settings
compressed_data = compress_gltf('input.glb', qp=14, qn=10, cl=9)
Command Line Interface
Compress a glTF/glb file:
python -m gltf_draco_transcoder input.glb output_compressed.glb
This will display compression statistics including file sizes and compression ratio.
Compression Options
The compress_gltf function accepts the following parameters:
-
Quantization Bits (default values shown):
qp=11: Position quantizationqt=10: Texture coordinate quantizationqn=8: Normal vector quantizationqc=8: Color quantizationqtg=8: Tangent quantizationqw=8: Weight quantizationqg=8: Generic attribute quantization
-
Compression Level:
cl=7: Compression effort (0-10, higher = better compression but slower)
Higher quantization bits = better quality but larger file sizes. Higher compression levels = better compression ratios but slower processing.
Development
Building from Source
This project uses scikit-build-core with CMake and vcpkg for dependency management.
Prerequisites
- Python 3.10+
- CMake 3.15+
- Git
- vcpkg (automatically installed on Linux via CI scripts)
Build Steps
# Clone the repository
git clone https://github.com/gongfan99/gltf_draco_transcoder.git
cd gltf_draco_transcoder
# Install build dependencies
pip install scikit-build-core setuptools-scm
# Build the package
python -m build
Project Structure
src/gltf_draco_transcoder/
├── __init__.py # Main API exports
├── loader.py # Python wrapper and ctypes bindings
├── py.typed # Type hints marker
└── _version.py # Version information (auto-generated)
cpp/
├── draco_transcoder_c_api.* # C API wrapper
└── draco_transcoder_lib.* # Core C++ implementation
vcpkg-overlays/draco/ # Custom Draco build configuration
vcpkg-triplets/ # Platform-specific build triplets
Platform Support
- Linux: x86_64 and ARM64 (manylinux/musllinux wheels)
- macOS: ARM64
- Windows: x86_64 (win_amd64 wheels)
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues on GitHub.
License
This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.
Credits
- Built on the Draco 3D data compression library
- Uses tinygltf for glTF file I/O
- Uses vcpkg for dependency management
- Packaging with scikit-build-core and cibuildwheel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gltf_draco_transcoder-0.2.3.tar.gz.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51a2704b3d67bbca9c4bc6c9a81311aea0f9eb4061d46caa076595ee8c759e9a
|
|
| MD5 |
7542586370c9220e11efaed3dd269254
|
|
| BLAKE2b-256 |
f0e3984fa0b57b8e256ff9c5997e96a3136229ec618b7a0d1bc539aba836965d
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3.tar.gz:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3.tar.gz -
Subject digest:
51a2704b3d67bbca9c4bc6c9a81311aea0f9eb4061d46caa076595ee8c759e9a - Sigstore transparency entry: 783004886
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-win_amd64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-win_amd64.whl
- Upload date:
- Size: 473.0 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4f1ce0796829146f7ccbf5d86ca4e02affb71c3c270448447bda11e3fde2e24
|
|
| MD5 |
11a202125bb8d7ccd8bb209d74410813
|
|
| BLAKE2b-256 |
62311c2ce8fc623a1a6a6d26ac63b96eee4db3ade38c37b4728a556060cf6b05
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-win_amd64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-win_amd64.whl -
Subject digest:
a4f1ce0796829146f7ccbf5d86ca4e02affb71c3c270448447bda11e3fde2e24 - Sigstore transparency entry: 783004898
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68dc9910d327d81e7c119f88a1d4c0af99a32db3cd9432864c335185092ed89f
|
|
| MD5 |
e77a45530e0758ae7c36045e1cb331cb
|
|
| BLAKE2b-256 |
f80767b5043cdc66f9165f261a17ebe4b762fc61c4c96555d970305119c57723
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_x86_64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_x86_64.whl -
Subject digest:
68dc9910d327d81e7c119f88a1d4c0af99a32db3cd9432864c335185092ed89f - Sigstore transparency entry: 783004893
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35fc839a162d1e513e5a711a33215b702fe592685346296ee0f7dfab9b12ebb9
|
|
| MD5 |
2893ab8b96e8522e344290dd6ae79ac0
|
|
| BLAKE2b-256 |
ae47ad6902d4111f9e61fcd978caca4e8a3582c5ce682becd0ee68ac8e6b48f2
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_aarch64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-musllinux_1_2_aarch64.whl -
Subject digest:
35fc839a162d1e513e5a711a33215b702fe592685346296ee0f7dfab9b12ebb9 - Sigstore transparency entry: 783004891
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dd0f1bc63b4855a92cebb187253cd41bc5e701954d60e481a6ec8efcbb2d61d
|
|
| MD5 |
935bc71be997357467b22b36e147df59
|
|
| BLAKE2b-256 |
7c80b360e8d79c762419ce74198ded3658e0368686a69cd23c652b26596981e2
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
8dd0f1bc63b4855a92cebb187253cd41bc5e701954d60e481a6ec8efcbb2d61d - Sigstore transparency entry: 783004908
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.5 MB
- Tags: Python 3, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b8bebffa5e4daa18e5ede53b958f24f217f77a02b8b02b9f77437dcbd584e12
|
|
| MD5 |
04717cf0e05299030bd412662f9abad3
|
|
| BLAKE2b-256 |
e527cba4ece89a58edf39ca41423c5aea6121981f8b0794b461b299b6760ed2e
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
1b8bebffa5e4daa18e5ede53b958f24f217f77a02b8b02b9f77437dcbd584e12 - Sigstore transparency entry: 783004910
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gltf_draco_transcoder-0.2.3-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: gltf_draco_transcoder-0.2.3-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f05f3b24c49ae695e4833574cf87425811e8d3ed9834188a86feb44404544b70
|
|
| MD5 |
32e2e52dbfb4986464b78090240b4688
|
|
| BLAKE2b-256 |
8d8328abcdece455af7d085b21311180c4640d43709fc479c60b7d4e342c6fab
|
Provenance
The following attestation bundles were made for gltf_draco_transcoder-0.2.3-py3-none-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on gongfan99/gltf_draco_transcoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gltf_draco_transcoder-0.2.3-py3-none-macosx_11_0_arm64.whl -
Subject digest:
f05f3b24c49ae695e4833574cf87425811e8d3ed9834188a86feb44404544b70 - Sigstore transparency entry: 783004903
- Sigstore integration time:
-
Permalink:
gongfan99/gltf_draco_transcoder@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/gongfan99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@350ae0977c43cf84f511c51fbeddb3a154dc6de0 -
Trigger Event:
push
-
Statement type: