The KTX File Format and Tools
KTX (Khronos Texture) is a lightweight file format for OpenGL® and Vulkan® textures. KTX files contain all the parameters needed for texture loading. A single file can contain anything from a simple base-level 2D texture through to a cubemap array texture with mipmaps. Texture payloads can be in Basis LZ/ETC1S or Basis UASTC formats, which can be transcoded to any GPU-supported format, in any of the block-compressed formats supported by OpenGL family and Vulkan APIs and extensions or in an uncompressed format. Basis LZ/ETC1S format is both block-compressed and supercompressed. Other formats can be supercompressed with Zstandard (zstd).
See the Khronos KTX landing page for more information about KTX and links to further information.
The original file format specification was created by Khronos’s OpenGL ES and ARB-OpenGL ES Convergence Working Groups. The Version 2.0 file format specification was created by the 3D Formats Working Group which is also responsible for glTF™️.
See the Khronos KTX Registry for more information about the specification.
The software in this repo includes
libktx, a library for reading and writing KTX files, a set of command line tools and
.wasm modules for
Downloadable binaries are available in the Releases section of this repo. Binaries of the commmand line tools and
libktx are available for GNU/Linux, macOS and windows. These packages include the resources necessary for developing applications that use
libktx. Binaries of the .wasm modules and JS wrappers are also available.
If you want to build the software yourself you will need to install CMake. See the repo’s BUILDING.md for complete instructions.
Using KTX Files
toktx, one of the tools in this repo, can be used to create KTX and KTX 2 files using .jpg, Netpbm or .png files as input. When creating the latter it can encode to Basis LZ/ETC1S or UASTC and can supercompress with zstd. It can create any texture structure: 1D, 2D, 3D, 1D & 2D arrays, cube maps and cube map arrays.
Other software that can be used to create and edit KTX version 1 files and are expected to be updated for version 2 include:
The Adreno1 texture tool from Qualcomm, a GUI tool for compression and visualization of textures.
Mali Texture Compression Tool2 from ARM, a GUI tool that can create and view files with either compressed or uncompressed textures.
PVRTexTool3 from Imagination Technology, a GUI tool that can create and view files with either compressed or uncompressed textures.
Compressonator, from AMD’s GPUOpen initiative, is a set of tools to allow artists and developers to more easily create compressed texture assets or model mesh optimizations and easily visualize the quality impact of various compression and rendering technologies. There is a glTF fork of Compressonator which in theory should support KTX 2 sooner but it is not receiving much love at the moment.
NVIDIA Texture Tools Exporter, available as a standalone GUI tool or a Photoshop Plugin. It supports loading from KTX1 and KTX2 textures and can export to KTX2.
1 Included in the Adreno SDK which can be downloaded from the Adreno GPU Tools and Resources page.
There are also tools that focus on viewing. These include:
PicoPixel which can be used for viewing KTX files & more and for debugging image handling in your applications. Windows only.
Image Viewer and Tonemapper which can be used for viewing, image comparisons and statistics, tonemapping and mipmap generation. This has experimental KTX 2 support. Windows only.
Kram can be used to encode, load, bundle, and view BC/ETC2/ASTC files as KTX/KTX2. Scripted support for KTX2 and Basis files using libktx tools. Windows/macOS with binary releases.
Using KTX files on the Web
A JS binding for
libktx is available for use with a
.wasm compilation of the library. See its documentation for details of how to use it.
Container-independent transcoder for JS parsers.
There is also a JS binding for and a
.wasm module of a container-independent transcoder for images encoded in Basis Universal format so those who wish to write their own parser in JS can do so. See its documentation for details of how to use it.
Using KTX 2 files in glTF
gltfpack can be used to update an existing glTF asset, creating textures encoded to Basis ETC1S/LZ or UASTC formats within a KTX2 container (-tc flag). Compression is performed using the
basisu executable and is thus only available in native builds.
gltf-transform can be used to update an existing glTF asset, creating textures encoded to Basis ETC1S/LZ or UASTC formats within a KTX2 container (
uastc commands). Compression is performed using the KTX-Software package and is only available via commandline.
Using KTX files natively
To report problems or suggest new functionality, please use the issues list in the GitHub repository.