Skip to main content

Python package for GLTF Draco transcoding with C++ backend

Project description

gltf_draco_transcoder

A high-performance Python package for compressing and decompressing 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 (x86_64 and ARM64)
  • Configurable: Fine-tune compression quality with quantization and compression level settings
  • Easy Integration: Simple Python API and command-line interface

Live Demo

Try the online demo to see Draco compression in action on glTF files. The demo uses the WebAssembly (WASM) port of the same C++ codebase as this Python package.

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 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 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

# Compress with custom quantization and compression level settings
# qp: quantization_position, qn: quantization_normal, cl: compression_level
compressed_data = compress_gltf('input.glb', qp=14, qn=10, cl=9)

Command Line Interface

Compress a 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 quantization
    • qt=10: Texture coordinate quantization
    • qn=8: Normal vector quantization
    • qc=8: Color quantization
    • qtg=8: Tangent quantization
    • qw=8: Weight quantization
    • qg=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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gltf_draco_transcoder-0.2.9.tar.gz (37.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gltf_draco_transcoder-0.2.9-py3-none-win_amd64.whl (474.9 kB view details)

Uploaded Python 3Windows x86-64

gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_x86_64.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.7 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

gltf_draco_transcoder-0.2.9-py3-none-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file gltf_draco_transcoder-0.2.9.tar.gz.

File metadata

  • Download URL: gltf_draco_transcoder-0.2.9.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gltf_draco_transcoder-0.2.9.tar.gz
Algorithm Hash digest
SHA256 71dad456c9a6e5b9f4e12f3fd56fc7d5c6879ff382f55dca0b124576e10efbb6
MD5 74d7294048ffc84048eb724cb413fa30
BLAKE2b-256 4e5f81f89f23e8c840b4c6c176039073ce83d3ec44b09b280ce9fa6d397e0658

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9.tar.gz:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bd455848424377f061fe1901b54dcd47e630c34dcffd0e9145b973ed94cdfb14
MD5 2f1a18030031b861f9a303a043996d5e
BLAKE2b-256 18ad6734274c13dc2b8dcf080442ce216bef3d2fffdcbdc32e7ac13c994a8dc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-win_amd64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fb88fdb3d72b55b9c9f66ae7ffa2cbffcf8eaad5a8df9ae38d75bc70885280d7
MD5 e379ea09613a94e3a969be9435f7890f
BLAKE2b-256 382075e7cd4a8913379c32c1c96f80280a63ebaf6aafd3f261af80e19ff2d1ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_x86_64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6ccbf9dd9df93ec8ea0bfd62ff6674167919614411404ae219b0e1609b5d06df
MD5 f272f7cee208d854eff965484d27dafe
BLAKE2b-256 18b1704b2331bee26ddc7e66f6b5357974ee08b52510c1b34c3cf5675dfb025b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-musllinux_1_2_aarch64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0762a2f69065a6a54fc8016db79cad9a31b795205c47c3cc44099b43bbae4811
MD5 a867816b8c77e5f07a22e0fbd3a4a1c5
BLAKE2b-256 1e93aca28e69ec3eac6f188397090a63cff7d37678154456ff10e93b34b808b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 80028495bc02e84b4f168eb7c43ba7d5c9981dfe3e633921269ce6a5c0e3abe4
MD5 99f701a5dd3575ae36055f99ffdbf18b
BLAKE2b-256 0186e57a1318e14f8084b8125ad7ee575475acc27e7c1b6d1edf57a69e728255

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.9-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f7aacb35ccde9fd7074506e10cf32926b23c0162b719ce4d965ca5e6671b0fa
MD5 efe627d44164abc219cd92c6499c1d72
BLAKE2b-256 225b6ff07ee1f264ae8012f642a039a87547c03c1c6eb2c96d68fa14f023159c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.9-py3-none-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page